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

NullPointerException PDFFont#getEncodingFromFont with a PDF book because Type1Encoding is null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.1
    • 1.4.0
    • Parsing
    • None

    Description

      A NullPointerException was thrown while extracting text from a PDF ebook. The exception was thrown in

      PDFFont#getEncodingFromFont line:

      [snip]
      encoding.addCharacterEncoding(index, name.replace("/", ""));
      [snip]

      encoding was null. The line that was scanned was "/Encoding 256 array 0 1 255

      {1 index exch /.notdef put}

      for". The array check however only checks for line.endsWith("array"). The NPE was fixed when using line.contains("array") instead.

      I have added a patch. The PDF is a PDF book with copyright so it cannot be attached as an example. The meta data of the document was:

      Acrobat Distiller 7.0 (Windows)
      PScript5.dll Version 5.2.2
      PDF-1.6

      Attachments

        1. PDFBOX-897.patch
          0.7 kB
          Martijn Brinkers

        Activity

          People

            adamnichols Adam Nichols
            martijn_brinkers Martijn Brinkers
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: