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

PDFBox crashes when a Type3 font don't have an embedded encoding.

    XMLWordPrintableJSON

Details

    • Patch, Important

    Description

      When running PDFBox on a pdf with WinAnsiEncoding for a Type3 font it crashes without any output.

      Exception in thread "main" java.lang.ClassCastException: org.apache.pdfbox.cos.COSName cannot be cast to org.apache.pdfbox.cos.COSDictionary
      at org.apache.pdfbox.pdmodel.font.PDType3Font.readEncoding(PDType3Font.java:82)
      at org.apache.pdfbox.pdmodel.font.PDType3Font.<init>(PDType3Font.java:66)
      at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:79)
      at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:143)
      at org.apache.pdfbox.contentstream.operator.text.SetFontAndSize.process(SetFontAndSize.java:60)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:841)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:498)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:472)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:181)
      at org.apache.pdfbox.contentstream.operator.DrawObject.process(DrawObject.java:65)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:841)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:498)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:472)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:181)
      at org.apache.pdfbox.contentstream.operator.DrawObject.process(DrawObject.java:65)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:841)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:498)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:472)
      at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150)
      at org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:141)
      at org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:360)
      at org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:288)
      at org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:235)
      at org.apache.pdfbox.tools.ExtractText.startExtraction(ExtractText.java:237)
      at org.apache.pdfbox.tools.ExtractText.main(ExtractText.java:82)
      at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:59)
      

      edit by tilman
      font is here:

      Root/Pages/Kids/[0]/Resources/XObject/X1/Resources/XObject/X3/Resources/Font/F10/Encoding
      

      Attachments

        1. example.pdf
          380 kB
          Daniel Persson
        2. type3_fixed.patch
          1 kB
          Daniel Persson

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              kalaspuffar Daniel Persson
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: