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

NPE while rendering files with type3 fonts

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7
    • Fix Version/s: 1.8.7
    • Component/s: None
    • Labels:

      Description

      I get this NPE with the files of PDFBOX-1145, PDFBOX-1794, PDFBOX-2023 in 1.8 only:

      java.lang.NullPointerException
      at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:210)
      at org.apache.pdfbox.pdmodel.font.Type3StreamParser.createImage(Type3StreamParser.java:59)
      at org.apache.pdfbox.pdmodel.font.PDType3Font.createImageIfNecessary(PDType3Font.java:80)
      at org.apache.pdfbox.pdmodel.font.PDType3Font.drawString(PDType3Font.java:102)
      at org.apache.pdfbox.pdfviewer.PageDrawer.processTextPosition(PageDrawer.java:256)
      at org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:499)
      at org.apache.pdfbox.util.operator.ShowText.process(ShowText.java:45)
      at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
      at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
      at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:135)
      at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
      at org.apache.pdfbox.util.TestPDFToImage.doTestFile(TestPDFToImage.java:232)
      at org.apache.pdfbox.util.TestPDFToImage.testRenderImage(TestPDFToImage.java:344)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at junit.framework.TestCase.runTest(TestCase.java:168)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:232)
      at junit.framework.TestSuite.run(TestSuite.java:227)
      at junit.textui.TestRunner.doRun(TestRunner.java:116)
      at junit.textui.TestRunner.start(TestRunner.java:180)
      at junit.textui.TestRunner.main(TestRunner.java:138)
      at org.apache.pdfbox.util.TestPDFToImage.main(TestPDFToImage.java:394)

      After fixing PDFStreamEngine.processStream() like this

              if (aPage == null)
              {
                  graphicsState = new PDGraphicsState();
              }
              else
              {
                  graphicsState = new PDGraphicsState(aPage.findCropBox());
              }
      

      I get another NPE:

      java.lang.NullPointerException
      at org.apache.pdfbox.pdmodel.font.Type3StreamParser.createImage(Type3StreamParser.java:60)
      at org.apache.pdfbox.pdmodel.font.PDType3Font.createImageIfNecessary(PDType3Font.java:80)
      at org.apache.pdfbox.pdmodel.font.PDType3Font.drawString(PDType3Font.java:102)
      at org.apache.pdfbox.pdfviewer.PageDrawer.processTextPosition(PageDrawer.java:256)
      at org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:506)
      at org.apache.pdfbox.util.operator.ShowText.process(ShowText.java:45)
      at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:564)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:275)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:242)
      at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:222)
      at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:135)
      at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
      at org.apache.pdfbox.util.TestPDFToImage.doTestFile(TestPDFToImage.java:232)
      at org.apache.pdfbox.util.TestPDFToImage.testRenderImage(TestPDFToImage.java:344)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at junit.framework.TestCase.runTest(TestCase.java:168)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:232)
      at junit.framework.TestSuite.run(TestSuite.java:227)
      at junit.textui.TestRunner.doRun(TestRunner.java:116)
      at junit.textui.TestRunner.start(TestRunner.java:180)
      at junit.textui.TestRunner.main(TestRunner.java:138)
      at org.apache.pdfbox.util.TestPDFToImage.main(TestPDFToImage.java:394)

        Attachments

          Activity

            People

            • Assignee:
              lehmi Andreas Lehmkühler
              Reporter:
              tilman Tilman Hausherr
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: