rguedes / PDFMerger

PDFMerger compatible with PHP5 for laravel
34 stars 43 forks source link

FPDI Compression problems #16

Open allstartechsolutions opened 5 years ago

allstartechsolutions commented 5 years ago

probably uses a compression technique which is not supported by the free parser shipped with FPDI.

It works with some PDF but most of the PDF will throw the error above

randomhoodie commented 5 years ago

This problem is due to the PDF version, as the error says, the FPDI parser is used to parse the pdfs for merge, but this parser has problems handling pdf versions 1.5 and up, the solution that I found, is to convert or downgrade the pdf files to version 1.4, I do this with ghostscript's ps2pdf14 command, like so:

$path = "Your_path_to_the_pdf"; $pdf_file = "Your_problematic_pdf.pdf"; $pdf_file_version_1dot4 = "pdf_good_for_merge.pdf" $cmd = "ps2pdf14 $path.$pdf_file $path.$pdf_file_version_1dot4; exec($cmd);

This will leave you with a pdf file that is good for merge. I have tested it with pdf versions 1.5 and 1.7, haven't come across a 1.6, but I doubt it wouln't work.

bhavesh1992 commented 4 years ago

I have fetch same issue. please guide how to fix this issue.