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

NullPointerException in PDTrueTypeFont.java getPath( )

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.25
    • 2.0.29, 3.0.0 PDFBox
    • Parsing
    • None
    • Linux server

    Description

      Since April we get the following NPE in our software.

      PDFBox is used to convert PDFs to images.

       

      java.lang.NullPointerException: null
          at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getPath(PDTrueTypeFont.java:470) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForGID(TTFGlyph2D.java:144) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:93) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:514) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:495) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:793) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:811) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:749) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextString(PDFStreamEngine.java:608) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.operator.text.ShowText.process(ShowText.java:56) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:939) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:514) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:492) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:282) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:355) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:272) ~[pdfbox-2.0.25.jar:2.0.25]
          at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:258) ~[pdfbox-2.0.25.jar:2.0.25]

      This is a bit strange, since I thought that this bug was fixed with PDFBOX-3488

      PdfBox is running on a linux server but when I tried to access the PDFs I failed to find the right one (over 1 million docs on that server).

      On the other hand the fix linked in the ticket points to the following implementation:

       

       @Override
       public GeneralPath getPath(int code) throws IOException{
         if (ttf.getGlyph() == null){
           throw new IOException("glyf table is missing in font " + getName());
         } 

      which does not exist anymore in 2.0.3 or higher:

       

      @Override
          public GeneralPath getPath(int code) throws IOException{
              int gid = codeToGID(code);
              GlyphData glyph = ttf.getGlyph().getGlyph(gid); 

      Any idea why an NPE might occur?

      `ttf` might be null or `getGlyph` returns null?

       

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            TeeWeTee Lonzak
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: