[
https://issues.apache.org/jira/browse/PDFBOX-5939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17921802#comment-17921802
]
Ryan McKay commented on PDFBOX-5939:
------------------------------------
I just tested, and it works! I got some warning messages as expected, but the
output pdf looks good, and no stack overflow.
{code:java}
$ java -jar pdfbox-app-3.0.5-20250127.193804-9.jar merge -i google-docs-1.pdf
-i form-elements.pdf -i playwright.pdf -o output.pdf
Jan 28, 2025 10:53:53 AM org.apache.pdfbox.multipdf.PDFCloneUtility
hasSelfReference
WARNING: COSDictionary object has a reference to itself: 29 0 R
Jan 28, 2025 10:53:53 AM org.apache.pdfbox.multipdf.PDFCloneUtility
hasSelfReference
WARNING: COSDictionary object has a reference to itself: 30 0 R
Jan 28, 2025 10:53:53 AM org.apache.pdfbox.multipdf.PDFCloneUtility
hasSelfReference
WARNING: COSDictionary object has a reference to itself: 31 0 R
Jan 28, 2025 10:53:53 AM org.apache.pdfbox.multipdf.PDFCloneUtility
hasSelfReference
WARNING: COSDictionary object has a reference to itself: 32 0 R
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself
Jan 28, 2025 10:53:53 AM
org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode
updateParentOpenCount
WARNING: Outline parent points to itself {code}
[^output.pdf]
> 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
> Components: Utilities
> Affects Versions: 2.0.33, 3.0.3 PDFBox
> Reporter: Ryan McKay
> Assignee: Tilman Hausherr
> Priority: Major
> Labels: StackOverflowError
> Fix For: 2.0.34, 3.0.5 PDFBox, 4.0.0
>
> Attachments: form-elements.pdf, google-docs-1.pdf, google-docs-2.pdf,
> image-2025-01-26-16-12-52-443.png, output.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: [email protected]
For additional commands, e-mail: [email protected]