[ 
https://issues.apache.org/jira/browse/PDFBOX-3830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053562#comment-16053562
 ] 

Jens Henrik Rauff Hansen commented on PDFBOX-3830:
--------------------------------------------------

Thank you Tilman. 
I will try to avoid large bookmark tree's in the future.

> multipdf.PDFMergerUtility error handling large documents
> --------------------------------------------------------
>
>                 Key: PDFBOX-3830
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3830
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.0.6
>            Reporter: Jens Henrik Rauff Hansen
>         Attachments: 062.pdf, 06.pdf
>
>
> org.apache.pdfbox.multipdf.PDFMergerUtility are having problems merging large 
> documents.
> I have folowing method and testcase:
> {code:java}
> public static File mergePdfFiles(List<File> files, File outputFile) throws 
> IOException {
>               PDFMergerUtility merger = new PDFMergerUtility();
>               merger.setDestinationStream(new FileOutputStream(outputFile));
>               for (Iterator<File> fileIt = files.iterator(); 
> fileIt.hasNext();) {
>                       merger.addSource(fileIt.next().getAbsolutePath());
>               }
>               merger.mergeDocuments(MemoryUsageSetting.setupMixed(30000000));
>               //              
> merger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
>               //              
> merger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly());
>               return outputFile;
>       }
> {code}
> {code:java}
> @Test
>       public void test() {
>               File outputFile;
>               try {
>                       outputFile = File.createTempFile("PDFMergerTest", 
> ".pdf");
>                       List<File> files = new ArrayList<File>();
>                       files.add(new File("src/test/resources/06.pdf"));
>                       files.add(new File("src/test/resources/062.pdf"));
>                       int totalPageCount = 0;
>                       for (File file : files) {
>                               totalPageCount += PDFUtil.countPages(file);
>                       }
>                       PDFMerger.mergePdfFiles(files, outputFile);
>                       assertEquals("Page numbers match", totalPageCount, 
> PDFUtil.countPages(outputFile));
>               } catch (IOException e1) {
>                       // TODO Auto-generated catch block
>                       e1.printStackTrace();
>               }
>       }
> {code}
> This does for all three MemoryUsageSetting "setupMainMemoryOnly(), 
> setupTempFileOnly(), setupMixed(30000000)" return the the following error:
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running dk.dataproces.utilities.pdf.test.PDFMergerTest
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.223 sec <<< 
> FAILURE!
> test(dk.dataproces.utilities.pdf.test.PDFMergerTest)  Time elapsed: 1.179 sec 
>  <<< ERROR!
> java.lang.StackOverflowError
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:76)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:108)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:136)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:99)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:136)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:99)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:136)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:99)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:136)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:99)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:136)
>       at 
> org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:99)
> ....................................AND THIS GOES ON FOR LONG IN THE CONSOLE



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to