Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4003

Can't retrieve number tree from structure tree

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      PDDocument doc = PDDocument.load(new File("GeneralForbearance.pdf"));
      Object value = doc.getDocumentCatalog().getStructureTreeRoot().getParentTree().getValue(0);
      

      The code above always fails when used on a PDF with a structure tree:

      Exception in thread "main" java.io.IOException: Error while trying to create value in number tree:org.apache.pdfbox.cos.COSBase.<init>(org.apache.pdfbox.cos.COSArray)
      	at org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.convertCOSToPD(PDNumberTreeNode.java:212)
      	at org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.getNumbers(PDNumberTreeNode.java:185)
      	at org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.getValue(PDNumberTreeNode.java:139)
      	at pdfboxpageimageextraction.MergeTest.main(MergeTest.java:29)
      Caused by: java.lang.NoSuchMethodException: org.apache.pdfbox.cos.COSBase.<init>(org.apache.pdfbox.cos.COSArray)
      	at java.lang.Classj.getConstructor0(Class.java:3082)
      	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
      	at org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.convertCOSToPD(PDNumberTreeNode.java:206)
      	... 3 more
      

      I suspect that it is related to the PDNumberTreeNode having been called with a COSBase class parameter in getParentTree().

      That one doesn't have a constructor with a parameter.

      The structure tree numbers tree has mixed contents, these can be arrays or dictionaries.

      What we need is some PD wrapper that can have both inside.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tilman Tilman Hausherr
            tilman Tilman Hausherr
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment