[ https://issues.apache.org/jira/browse/PDFBOX-5801?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rodrigo Schonardt updated PDFBOX-5801: -------------------------------------- Description: {{When i try to merge the attached file with a cover the error happens:}} {quote}{{>>java.lang.StackOverflowError}} {{>> at java.base/sun.nio.cs.UTF_8$Decoder.decodeLoop(UTF_8.java:414)}} {{UTF_8.java:414}} {{>> at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:578)}} {{CharsetDecoder.java:578}} {{>> at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:801)}} {{CharsetDecoder.java:801}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.decodeBuffer(BaseParser.java:885)}} {{BaseParser.java:885}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSName(BaseParser.java:872)}} {{BaseParser.java:872}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionaryNameValuePair(BaseParser.java:368)}} {{BaseParser.java:368}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionary(BaseParser.java:289)}} {{BaseParser.java:289}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseDirObject(BaseParser.java:915)}} {{BaseParser.java:915}} {{>> at org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:737)}} {{COSParser.java:737}} {{>> at org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:671)}} {{COSParser.java:671}} {{>> at org.apache.pdfbox.pdfparser.COSParser.dereferenceCOSObject(COSParser.java:625)}} {{COSParser.java:625}} {{>> at org.apache.pdfbox.cos.COSObject.getObject(COSObject.java:121)}} {{COSObject.java:121}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.hasSelfReference(PDFCloneUtility.java:249)}} {{PDFCloneUtility.java:249}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSDictionary(PDFCloneUtility.java:176)}} {{PDFCloneUtility.java:176}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSBaseForNewDocument(PDFCloneUtility.java:122)}} {{PDFCloneUtility.java:122}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:100)}} {{PDFCloneUtility.java:100}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSBaseForNewDocument(PDFCloneUtility.java:110)}} {{PDFCloneUtility.java:110}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:100)}} {{{}PDFCloneUtility.java:100{}}}{{{{}}{}}} {quote} The code is the following, tried different configs but none helped: {code:java} PDFMergerUtility merger = new PDFMergerUtility(); merger.addSource( cover ); merger.addSource( file ); merger.setDestinationFileName( location ); merger.mergeDocuments( null ); {code} A similar error happens if i try to extract a page of the file and save it in a new file: {quote} >>java.lang.StackOverflowError >> at java.base/java.util.HashMap.putVal(HashMap.java:631) HashMap.java:631 >> at java.base/java.util.HashMap.put(HashMap.java:612) HashMap.java:612 >> at >> org.apache.pdfbox.pdfwriter.compress.COSObjectPool.put(COSObjectPool.java:80) COSObjectPool.java:80 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addObjectToPool(COSWriterCompressionPool.java:141) COSWriterCompressionPool.java:141 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addStructure(COSWriterCompressionPool.java:179) COSWriterCompressionPool.java:179 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addElements(COSWriterCompressionPool.java:219) COSWriterCompressionPool.java:219 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addStructure(COSWriterCompressionPool.java:188) COSWriterCompressionPool.java:188 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addElements(COSWriterCompressionPool.java:219) {quote} The code is the following: {code:java} PDDocument pdf = Loader.loadPDF( file ); int pageCount = pdf.getNumberOfPages(); for ( int i = 0; i < pageCount; i++) { PDDocument singlePageDocument = new PDDocument(); PDPage page = pdf.getPage(i); singlePageDocument.addPage(page); singlePageDocument.save( location + (i + 1) + ".pdf"); singlePageDocument.close(); } pdf.close(); {code} I believe theres is something to do with the specific structure of the file, considering i was able to use way bigger files, both in pages and in size without problems. Also tried to use the same file on itext and no problem was found. was: {{When i try to merge the attached file with a cover the error happens:}} {quote}{{>>java.lang.StackOverflowError}} {{>> at java.base/sun.nio.cs.UTF_8$Decoder.decodeLoop(UTF_8.java:414)}} {{UTF_8.java:414}} {{>> at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:578)}} {{CharsetDecoder.java:578}} {{>> at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:801)}} {{CharsetDecoder.java:801}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.decodeBuffer(BaseParser.java:885)}} {{BaseParser.java:885}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSName(BaseParser.java:872)}} {{BaseParser.java:872}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionaryNameValuePair(BaseParser.java:368)}} {{BaseParser.java:368}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionary(BaseParser.java:289)}} {{BaseParser.java:289}} {{>> at org.apache.pdfbox.pdfparser.BaseParser.parseDirObject(BaseParser.java:915)}} {{BaseParser.java:915}} {{>> at org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:737)}} {{COSParser.java:737}} {{>> at org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:671)}} {{COSParser.java:671}} {{>> at org.apache.pdfbox.pdfparser.COSParser.dereferenceCOSObject(COSParser.java:625)}} {{COSParser.java:625}} {{>> at org.apache.pdfbox.cos.COSObject.getObject(COSObject.java:121)}} {{COSObject.java:121}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.hasSelfReference(PDFCloneUtility.java:249)}} {{PDFCloneUtility.java:249}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSDictionary(PDFCloneUtility.java:176)}} {{PDFCloneUtility.java:176}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSBaseForNewDocument(PDFCloneUtility.java:122)}} {{PDFCloneUtility.java:122}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:100)}} {{PDFCloneUtility.java:100}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSBaseForNewDocument(PDFCloneUtility.java:110)}} {{PDFCloneUtility.java:110}} {{>> at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:100)}} {{{}PDFCloneUtility.java:100{}}}{{{{}}{}}} {quote} The code is the following, tried different configs but none helped: {code:java} PDFMergerUtility merger = new PDFMergerUtility(); merger.addSource( cover ); merger.addSource( file ); merger.setDestinationFileName( location ); merger.mergeDocuments( null ); {code} A similar error happens if i try to extract a page of the file and save it in a new file: {quote} >>java.lang.StackOverflowError >> at java.base/java.util.HashMap.putVal(HashMap.java:631) HashMap.java:631 >> at java.base/java.util.HashMap.put(HashMap.java:612) HashMap.java:612 >> at >> org.apache.pdfbox.pdfwriter.compress.COSObjectPool.put(COSObjectPool.java:80) COSObjectPool.java:80 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addObjectToPool(COSWriterCompressionPool.java:141) COSWriterCompressionPool.java:141 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addStructure(COSWriterCompressionPool.java:179) COSWriterCompressionPool.java:179 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addElements(COSWriterCompressionPool.java:219) COSWriterCompressionPool.java:219 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addStructure(COSWriterCompressionPool.java:188) COSWriterCompressionPool.java:188 >> at >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addElements(COSWriterCompressionPool.java:219) {quote} The code is the following: {code:java} PDDocument pdf = Loader.loadPDF( file ); int pageCount = pdf.getNumberOfPages(); for ( int i = 0; i < pageCount; i++) { PDDocument singlePageDocument = new PDDocument(); PDPage page = pdf.getPage(i); singlePageDocument.addPage(page); singlePageDocument.save( location + (i + 1) + ".pdf"); singlePageDocument.close(); } pdf.close(); {code} I believe theres is something to do with the specific structure of the file, considering i was able to use way bigger files, both in pages and in size without problems. Also tried to use the same file on itext and no problem was found. > StackOverflowError with specific document > ----------------------------------------- > > Key: PDFBOX-5801 > URL: https://issues.apache.org/jira/browse/PDFBOX-5801 > Project: PDFBox > Issue Type: Bug > Affects Versions: 3.0.2 PDFBox > Environment: Windows 10 Pro - 19045.3208 > openjdk version "13.0.2" 2020-01-14 > Memory: -Xmx4G -Xms100m > Reporter: Rodrigo Schonardt > Priority: Major > Labels: stack-overflow > Attachments: arquivo.pdf > > > {{When i try to merge the attached file with a cover the error happens:}} > {quote}{{>>java.lang.StackOverflowError}} > {{>> at java.base/sun.nio.cs.UTF_8$Decoder.decodeLoop(UTF_8.java:414)}} > {{UTF_8.java:414}} > {{>> at > java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:578)}} > {{CharsetDecoder.java:578}} > {{>> at > java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:801)}} > {{CharsetDecoder.java:801}} > {{>> at > org.apache.pdfbox.pdfparser.BaseParser.decodeBuffer(BaseParser.java:885)}} > {{BaseParser.java:885}} > {{>> at > org.apache.pdfbox.pdfparser.BaseParser.parseCOSName(BaseParser.java:872)}} > {{BaseParser.java:872}} > {{>> at > org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionaryNameValuePair(BaseParser.java:368)}} > {{BaseParser.java:368}} > {{>> at > org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionary(BaseParser.java:289)}} > {{BaseParser.java:289}} > {{>> at > org.apache.pdfbox.pdfparser.BaseParser.parseDirObject(BaseParser.java:915)}} > {{BaseParser.java:915}} > {{>> at > org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:737)}} > {{COSParser.java:737}} > {{>> at > org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:671)}} > {{COSParser.java:671}} > {{>> at > org.apache.pdfbox.pdfparser.COSParser.dereferenceCOSObject(COSParser.java:625)}} > {{COSParser.java:625}} > {{>> at org.apache.pdfbox.cos.COSObject.getObject(COSObject.java:121)}} > {{COSObject.java:121}} > {{>> at > org.apache.pdfbox.multipdf.PDFCloneUtility.hasSelfReference(PDFCloneUtility.java:249)}} > {{PDFCloneUtility.java:249}} > {{>> at > org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSDictionary(PDFCloneUtility.java:176)}} > {{PDFCloneUtility.java:176}} > {{>> at > org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSBaseForNewDocument(PDFCloneUtility.java:122)}} > {{PDFCloneUtility.java:122}} > {{>> at > org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:100)}} > {{PDFCloneUtility.java:100}} > {{>> at > org.apache.pdfbox.multipdf.PDFCloneUtility.cloneCOSBaseForNewDocument(PDFCloneUtility.java:110)}} > {{PDFCloneUtility.java:110}} > {{>> at > org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:100)}} > {{{}PDFCloneUtility.java:100{}}}{{{{}}{}}} > {quote} > The code is the following, tried different configs but none helped: > {code:java} > PDFMergerUtility merger = new PDFMergerUtility(); > merger.addSource( cover ); > merger.addSource( file ); > merger.setDestinationFileName( location ); > merger.mergeDocuments( null ); {code} > A similar error happens if i try to extract a page of the file and save it in > a new file: > {quote} >>java.lang.StackOverflowError > >> at java.base/java.util.HashMap.putVal(HashMap.java:631) > HashMap.java:631 > >> at java.base/java.util.HashMap.put(HashMap.java:612) > HashMap.java:612 > >> at > >> org.apache.pdfbox.pdfwriter.compress.COSObjectPool.put(COSObjectPool.java:80) > COSObjectPool.java:80 > >> at > >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addObjectToPool(COSWriterCompressionPool.java:141) > COSWriterCompressionPool.java:141 > >> at > >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addStructure(COSWriterCompressionPool.java:179) > COSWriterCompressionPool.java:179 > >> at > >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addElements(COSWriterCompressionPool.java:219) > COSWriterCompressionPool.java:219 > >> at > >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addStructure(COSWriterCompressionPool.java:188) > COSWriterCompressionPool.java:188 > >> at > >> org.apache.pdfbox.pdfwriter.compress.COSWriterCompressionPool.addElements(COSWriterCompressionPool.java:219) > {quote} > The code is the following: > {code:java} > PDDocument pdf = Loader.loadPDF( file ); > > int pageCount = pdf.getNumberOfPages(); > > for ( int i = 0; i < pageCount; i++) { > PDDocument singlePageDocument = new PDDocument(); > PDPage page = pdf.getPage(i); > singlePageDocument.addPage(page); > singlePageDocument.save( location + (i + 1) + ".pdf"); > singlePageDocument.close(); > } > > pdf.close(); {code} > I believe theres is something to do with the specific structure of the file, > considering i was able to use way bigger files, both in pages and in size > without problems. > Also tried to use the same file on itext and no problem was found. -- 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