Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.0.22
-
None
Description
I'm having a similar issue that have been fixed in PDFBOX-4969.
In my case, the IndexOutOfBoundsException occurs inside PDNameTreeNode, and not inside PDNumberTreeNode.
java.lang.IndexOutOfBoundsException: Index: 81, Size: 81 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at org.apache.pdfbox.cos.COSArray.getObject(COSArray.java:188) at org.apache.pdfbox.pdmodel.common.PDNameTreeNode.getNames(PDNameTreeNode.java:272) at org.apache.pdfbox.multipdf.PDFMergerUtility.getIDTreeAsMap(PDFMergerUtility.java:1036) at org.apache.pdfbox.multipdf.PDFMergerUtility.getIDTreeAsMap(PDFMergerUtility.java:1051) at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeIDTree(PDFMergerUtility.java:1008) at org.apache.pdfbox.multipdf.PDFMergerUtility.appendDocument(PDFMergerUtility.java:877) at org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:459) at org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:346)
Unfortunately, I can't share the document that reproduce the issue.
I tried the same approach to fix it :
public Map<String, T> getNames() throws IOException { COSArray namesArray = node.getCOSArray(COSName.NAMES); if( namesArray != null ) { Map<String, T> names = new LinkedHashMap<String, T>(); if (namesArray.size() % 2 != 0) { LOG.warn("Numbers array has odd size: " + namesArray.size()); } for (int i = 0; i + 1 < namesArray.size(); i += 2) { COSBase base = namesArray.getObject(i); if (!(base instanceof COSString)) { throw new IOException("Expected string, found " + base + " in name tree at index " + i); ....
But I'm getting the IOException :
Caused by: java.io.IOException: Expected string, found COSDictionary{[...] in name tree at index 0
And indeed, namesArray contains a COSObject at first index :
Attachments
Attachments
Issue Links
- is duplicated by
-
PDFBOX-5357 java.lang.IndexOutOfBoundsException
- Closed
- relates to
-
PDFBOX-4969 java.lang.IndexOutOfBoundsException
- Closed