Ryan McKay created PDFBOX-5939: ---------------------------------- Summary: Merge docs with specific characteristics causes stack overflow Key: PDFBOX-5939 URL: https://issues.apache.org/jira/browse/PDFBOX-5939 Project: PDFBox Issue Type: Bug Affects Versions: 3.0.3 PDFBox, 2.0.33 Environment: Mac local development env Linux production env Reporter: Ryan McKay Attachments: form-elements.pdf, google-docs-1.pdf, google-docs-2.pdf
Merging specific docs in a specific order causes a stack overflow. We've noticed that a common thread is that one of the docs was exported from Google Docs. Order matters. If a Google docs PDF is followed by another Google docs PDF (either itself again or a different one) or a PDF with form elements, the problem is encountered. Interspersing other docs that don't have those characteristics doesn't affect the outcome. Form elements followed by Google docs works fine also. The specific code that encounters the problem is as follows: {code:java} PDFMergerUtility PDFmerger = new PDFMergerUtility(); PDFmerger.setDestinationFileName(outputFile.getAbsolutePath()); for (File f : files) { PDFmerger.addSource(f); } PDFmerger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly()); {code} We also encounter the problem using the CLI's pdfbox-app-2.0.22.jar and pdfbox-app-3.0.3.jar. We found that adding the following fixed the problem: {code:java} PDFmerger.setDocumentMergeMode(PDFMergerUtility.DocumentMergeMode.OPTIMIZE_RESOURCES_MODE); {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org