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

createDescendantFont throws 'Invalid font type: COSName{Font}' when reading pdf

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: 2.0.11
    • Fix Version/s: None
    • Component/s: PDModel, Text extraction
    • Labels:
      None
    • Environment:
      Java 8, macOS Mojave 10.14.6

      Description

      Our system needs to extract text from pdfs. It's been working for over a year, but today we started seeing errors when we tried to process some pdfs. This has only affected a small number of pdfs so far, but when it does come up we are unable to extract the text. Following is the pertinent part of the stacktrace:

      Caused by: java.io.IOException: Invalid font type: COSName{Font}Caused by: java.io.IOException: Invalid font type: COSName{Font} at org.apache.pdfbox.pdmodel.font.PDFontFactory.createDescendantFont(PDFontFactory.java:129) at org.apache.pdfbox.pdmodel.font.PDType0Font.<init>(PDType0Font.java:192) at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:83) at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:146) at org.apache.pdfbox.contentstream.operator.text.SetFontAndSize.process(SetFontAndSize.java:60) at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:848) at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:503) at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:477) at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150) at org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:139) at org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:391) at org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:319) at org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:266)

      We have no control over the content of the pdfs, but we have to be able to extract the text from them. Is there a workaround for this or some way to configure PDFBox to handle this properly?

      The offending pdfs are over 60 MB so I can't attach one to this issue.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              slitster Samuel Litster
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: