Drawing in a PDF file

后端 未结 3 1693
忘掉有多难
忘掉有多难 2021-02-20 14:38

I would like to draw in a PDF file.

Example: Open the PDF file and get such drawing tools like circle, square, text etc... Using these tools will draw shapes on the PDF

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-20 15:18

    TCPDF (tcpdf.org) seems to handle PDF graphics methods.

    Cf. examples/example_012.php:

    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    
    // Line
    $pdf->Text(5, 4, 'Line examples');
    $pdf->Line(5, 10, 80, 30, $style);
    $pdf->Line(5, 10, 5, 30, $style2);
    $pdf->Line(5, 10, 80, 10, $style3);
    // Rect
    $pdf->Text(100, 4, 'Rectangle examples');
    $pdf->Rect(100, 10, 40, 20, 'DF', $style4, array(220, 220, 200));
    $pdf->Rect(145, 10, 40, 20, 'D', array('all' => $style3));
    

    And its GitHub project tecnickcom/tcpdf indicated being 100% PHP.
    However, this search shows it can create and modify a new PDF document. It might not be able to open and modify an existing one.

提交回复
热议问题