Laravel edit existing pdf

后端 未结 1 1228
旧时难觅i
旧时难觅i 2021-01-03 04:30

I don\'t know how to edit an existing pdf file with Laravel.

I have found many plugin for create PDF but no one help me in my problem.

Can anyone know how to

相关标签:
1条回答
  • 2021-01-03 04:46

    There is no built-in way for Laravel to edit PDFs. You can of course use external libs, such as FPDF with the FPDI extension to modify PDFs - the result is a new PDF file. There is also a paid lib PDFlib that is capable of editing PDFs.

    To install FPDF + FPDI in Laravel you just need to run:

    composer require setasign/fpdf && composer require setasign/fpdi
    

    This will install the base FPDF lib + the extension FPDI. Afterwards you can create a new instance and edit your PDF with:

    $pdf = new \FPDI();
    $pdf->setSourceFile('PATH/TO/SOURCEFILE');
    

    Please make yourself comfortable with the FPDI documentation

    Update: With FPDI you cannot directly edit a PDF file. All FPDI does is extracting content from a given PDF file into a reusable format - the result is a complete new PDF. This information can also be found in the FAQ of FPDI.

    0 讨论(0)
提交回复
热议问题