Forum


Replies: 4   Views: 2020
How to repair a pdf that can't be merged
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by pks  · 25-08-2021 - 20:21

I'm trying to merge multiple PDFs with MultiMerge mergePdf() function, which works most of the time. In a specific case/file, the process fails with this error:

Fatal error: Uncaught exception 'Exception' with message 'TCPDF_PARSER ERROR: decodeFilterFlateDecode: invalid code' 

I've followed the tutorial here:
https://www.phpdocx.com/documentation/cookbook/repair-PDF
and in case the merging process fails, I automatically repair all pdfs with pdftocairo then I try to merge again. WIth the repaired PDFs now I get to a different error, an infinite loop crash:

http://prntscr.com/1qiino1

Furthermore, I discovered that even with good files that can be merged by phpdocx, if I go through the pdftocairo repair process before, I get to the exact same infinite loop that ends with an out of memory error.

Is this a corrupted file issue, pdftocairo messes up the files worse than they are? Both the original and the repaired pdfs open fine in readers, browsers, etc. Has anyone experienced anything similar? I can provide the file in case on private if needed.