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

Thomas B. edited comment on PDFBOX-5072 at 1/6/21, 7:50 PM:
------------------------------------------------------------

Thank you for your quick reply and for the fix.

For the second problem, I don't understand why. Thousands of files are working 
perfectly, this is the first time we're having this issue with a specific pdf 
file coming from an user. Although the file seems to be normal. Do you have any 
Idea of what could be the error ?


was (Author: thomas b.):
Thank you for your quick reply and for the fixe.

For the second problem, I don't understand why. Thousands of files are working 
perfectly, this is the first time we're having this issue with a specific pdf 
file coming from an user. Although the file seems to be normal. Do you have any 
Idea of what could be the error ?

> java.lang.IndexOutOfBoundsException
> -----------------------------------
>
>                 Key: PDFBOX-5072
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5072
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel, Utilities
>    Affects Versions: 2.0.22
>            Reporter: Thomas B.
>            Priority: Critical
>             Fix For: 2.0.23, 3.0.0 PDFBox
>
>         Attachments: image-2021-01-06-14-56-41-433.png
>
>
> 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.
> {code:java}
> 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)
> {code}
> Unfortunately, I can't share the document that reproduce the issue.
> I tried the same approach to fix it :
> {code:java}
> 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);
> ....{code}
> But I'm getting the IOException :
> {code:java}
> Caused by: java.io.IOException: Expected string, found COSDictionary{[...] in 
> name tree at index 0
> {code}
> And indeed, _namesArray_ contains a COSObject at first index :
> !image-2021-01-06-14-56-41-433.png!
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to