I want to merge several pdf files. How can I do that ?
What I have so far is this.
I'm trying to use this package myokyawhtun/PDFMerger.
include base_path('vendor/myokyawhtun/pdfmerger/PDFMerger.php');
$pdf = new \PDFMerger;
$pdf->addPDF(public_path('doc/uploads/doc_1.pdf'), 'all');
$pdf->addPDF(public_path('doc/uploads/doc_2.pdf'), 'all');
$pdf->merge('file', public_path('doc/files/test.pdf'));
The errors are different depending on what files I try to merge.
- If I try to merge the same pdf twice, the file is generated but all blank.
- If I try with the code above, I get HTTP ERROR 500.
- If I try with more files, I get tcpdi_parser - Out of memory error.
Bottom line is that it doesn't seem to work.
I already tried several other packages that use FPDI. Problem is that it only works with pdf versions equal or lower to 1.4 (if I'm not mistaken). So using any of those doesn't seem to be an option.
I'm well aware that the question has already been asked, none of the solution seems to work.