[ 
https://issues.apache.org/jira/browse/PDFBOX-5939?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr resolved PDFBOX-5939.
-------------------------------------
    Resolution: Fixed

Thanks for the feedback!

> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to