myokyawhtun / PDFMerger

PDFMerger compatible for PHP 5, PHP 7, and PHP 8
235 stars 272 forks source link

Timeout #30

Open drtothferenc19 opened 6 years ago

drtothferenc19 commented 6 years ago

I want to merge several PDF documents, all of them contain one page. It takes 1-2 seconds for ~20 files which is great. There is one exception: when I want to merge invoices which are issued by an online billing software. Even if I want to merge two files only, I get timeout error Fatal error: Maximum execution time of 120 seconds exceeded in .../PDFMerger/tcpdf/tcpdi_parser.php on line 725 The line number is different at every running. The size of the PDF file is around 100kb but PDFMerger can easily merge much bigger files when I need it. When I modify the PDF files (e.g. compress) PDFMerger can merge them. Merging the original files by different online services is also working.

Any suggestion?

taylorbohannan commented 6 years ago

I am having this exact same issue. There is something about these software-generated Invoices that is breaking tcpdf. The PDF says it was produced by "PDFlib+PDI 9.0.4 (PHP5/Win32)". When the server tries to perform the merge I can see the worker process's memory usage continuously increase until it reaches PHP's configured memory limit. Once the limit is reached an error is returned indicated the memory has been exhausted. I have tried to debug by removing the limit (memory_limit = -1) but then the process just grows and grows until all memory is consumed. We've used this code for many years and are now all of a sudden having these issues. Seems like whatever is generating these Invoices is used by a lot of people and was updated in the 2nd half of 2017.

How can I get additional debug information?