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

NPE when Transparency Group is missing the BBox

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.26
    • 2.0.27, 3.0.0 PDFBox
    • Rendering
    • None

    Description

      Some files contain transparency groups with no BBox. When this happens, PDFBox rendering code throws a NullPointerException in the TransparencyGroup constructor:

       

      // transform the bbox
      GeneralPath transformedBox = form.getBBox().transform(transform);
                                        \_______/ 
                                     NPE when its null

      The following is a screenshot taken from pdf-debugger when trying to open a file with has this issue:

      The stack trace:

      java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "org.apache.pdfbox.pdmodel.common.PDRectangle.transform(org.apache.pdfbox.util.Matrix)" because the return value of "org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup.getBBox()" is null
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.done(PagePane.java:485)
          java.desktop/sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
          java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
          java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
      Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "org.apache.pdfbox.pdmodel.common.PDRectangle.transform(org.apache.pdfbox.util.Matrix)" because the return value of "org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup.getBBox()" is null
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.done(PagePane.java:465)
          java.desktop/sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
          java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
          java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
      Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.pdfbox.pdmodel.common.PDRectangle.transform(org.apache.pdfbox.util.Matrix)" because the return value of "org.apache.pdfbox.pdmodel.graphics.form.PDTransparencyGroup.getBBox()" is null
          org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1672)
          org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1637)
          org.apache.pdfbox.rendering.PageDrawer.showTransparencyGroupOnGraphics(PageDrawer.java:1575)
          org.apache.pdfbox.rendering.PageDrawer.showTransparencyGroup(PageDrawer.java:1553)
          org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:81)
          org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:966)
          org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:541)
          org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:516)
          org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155)
          org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:279)
          org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:355)
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:453)
          org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:435)
          java.base/java.lang.Thread.run(Thread.java:832)
       

      The following is an example file that reproduces this problem:

      getbbox-null.pdf

       

      A potential fix PR: https://github.com/apache/pdfbox/pull/145

      Attachments

        1. image-2022-07-04-14-55-28-527.png
          318 kB
          Henry Iguaro
        2. getbbox-null.pdf
          204 kB
          Henry Iguaro

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              henry-canva Henry Iguaro
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: