Emanuel Greisen created PDFBOX-3513:
---------------------------------------

             Summary: PDFType3Font can have Encoding which is not a 
COSDictionary
                 Key: PDFBOX-3513
                 URL: https://issues.apache.org/jira/browse/PDFBOX-3513
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 2.0.3
            Reporter: Emanuel Greisen


I tried the "ExtractTextByArea" with a PDF from my bank and go the following 
stacktrace:

{code}
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:70)
        at 
org.apache.pdfbox.pdmodel.font.PDType3Font.<init>(PDType3Font.java:57)
        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:815)
        at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
        at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
        at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
        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.PDFTextStripperByArea.extractRegions(PDFTextStripperByArea.java:130)
{code}

I can read the PDF with evince, pdftk, lesspipe to extract text. I cannot 
upload the file as it is a bank statement with content I will not share.

Debugging the application I found that the return from PDType3Font.java:69

{code}
dict.getDictionaryObject(COSName.ENCODING)
{code}

Is an object of type: "COSName" with the name property set to "WinAnsiEncoding".

I hope this helps - despite the fact that I cannot share the example PDF.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to