Laravel edit existing pdf

大兔子大兔子 提交于 2019-12-06 03:42:11

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!