Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3058 Support TIKA Migration to PDFBox 2.0
  3. PDFBOX-3051

COSArray.getObject() incorrect handling of indirect reference to COSNull

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.10, 1.8.11, 2.0.0
    • Fix Version/s: 1.8.11, 2.0.0
    • Component/s: PDModel
    • Labels:
      None

      Description

      The attached (broken) file has this exception when displaying page 10:

      java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.io.IOException: Error: Unknown annotation type COSNull{}
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.done(PagePane.java:175)
          sun.swing.AccumulativeRunnable.run(Unknown Source)
          java.security.AccessController.doPrivileged(Native Method)
          java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Error: Unknown annotation type COSNull{}
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.done(PagePane.java:164)
          sun.swing.AccumulativeRunnable.run(Unknown Source)
          java.security.AccessController.doPrivileged(Native Method)
          java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      Caused by: java.io.IOException: Error: Unknown annotation type COSNull{}
          org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.createAnnotation(PDAnnotation.java:164)
          org.apache.pdfbox.pdmodel.PDPage.getAnnotations(PDPage.java:664)
          org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:181)
          org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:208)
          org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:139)
          org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:68)
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:155)
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:138)
          java.lang.Thread.run(Unknown Source)
      

      The cause is this code:

          public COSBase getObject( int index )
          {
              Object obj = objects.get( index );
              if( obj instanceof COSObject )
              {
                  obj = ((COSObject)obj).getObject();
              }
              else if( obj instanceof COSNull )
              {
                  obj = null;
              }
              return (COSBase)obj;
          }
      

      i.e. a COSObject that points to a COSNull object isn't returned as null, but as COSNull. COSDictionary.getDictionaryObject() does not have this bug.

      Solution: remove the "else".

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tilman Tilman Hausherr
                Reporter:
                tilman Tilman Hausherr
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: