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

Tilman Hausherr resolved PDFBOX-5072.
-------------------------------------
      Assignee: Tilman Hausherr
    Resolution: Fixed

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

Reply via email to