Mohamed Salah
Mohamed Salah

Reputation: 11

How can I merge two pdfs with editable form elements in Laravel 10 without loosing the editing feature

I am using laravel snappy pdf library to generate a pdf file with form elements, and save it to a predefined storage disk using the following code

$fileName = 'run-' . time() . '.pdf';

$pdf = SnappyPdf::loadView('pdfs.run', compact('run', 'data'))->setPaper('A4')->setOption('enable-forms', true);

Storage::disk('run-pdfs')->put($fileName, $pdf->output());

then I'm using the webklex laravel pdf merger library to merge some other pdf files attached be the user

$merger = PDFMergerFacade::init();
$merger->addPDF(Storage::disk('run-pdfs')->path($fileName));
$merger->addPDF(Storage::disk('run-attaches')->path('attach1.pdf');
$merger->addPDF(Storage::disk('run-attaches')->path('attach2.pdf');
$merger->merge();
$merger->save(Storage::disk('run-pdfs')->path('merged-file.pdf'));

the problem is the final generated pdf file (the one holds all of the pdfs as one file) lost the form editing feature

anyone knows how to merge the pdfs without loosing the enable-form feature and keep the pdf editable

I tried so many pdf merger php libraries, but nothing keeps the form element editable

Upvotes: 1

Views: 164

Answers (0)

Related Questions