You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2011/06/09 09:29:58 UTC

[jira] [Resolved] (PDFBOX-1008) NPE warn during text extraction caused by character encoding not set

     [ https://issues.apache.org/jira/browse/PDFBOX-1008?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-1008.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.6.0
         Assignee: Andreas Lehmkühler

I added a fix in revision 1133689 so that no longer AFM metrics are used with non Type1 fonts.

Thanks for the detailed report!

> NPE warn during text extraction caused by character encoding not set
> --------------------------------------------------------------------
>
>                 Key: PDFBOX-1008
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1008
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Text extraction
>    Affects Versions: 1.5.0
>            Reporter: Stephane Lacoin
>            Assignee: Andreas Lehmkühler
>            Priority: Minor
>             Fix For: 1.6.0
>
>         Attachments: TestPDFEncodingWarn.java, nutcracker.pdf
>
>
> During text extraction, the following NPE stack is printed with a warn level. 
> 17:34:58,762 WARN  [PDFStreamEngine] java.lang.NullPointerException
> java.lang.NullPointerException
> 	at org.apache.pdfbox.pdmodel.font.PDSimpleFont.getFontHeight(PDSimpleFont.java:136)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:408)
> 	at org.apache.pdfbox.util.operator.ShowTextGlyph.process(ShowTextGlyph.java:62)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:551)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:274)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:251)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:225)
> 	at org.apache.pdfbox.util.PDFTextStripper.processPage(PDFTextStripper.java:442)
> 	at org.apache.pdfbox.util.PDFTextStripper.processPages(PDFTextStripper.java:366)
> 	at org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:322)
> 	at org.apache.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:242)
> 	at org.nuxeo.ecm.core.convert.plugins.tests.TestPDFEncodingWarn.extract(TestPDFEncodingWarn.java:36)
> Digging in the problem, I've found that the encoding field of the true type font was not set during the dictionary load. 
> Thread [main] (Suspended (breakpoint at line 113 in PDTrueTypeFont))	
> 	PDTrueTypeFont.<init>(COSDictionary) line: 113	
> 	PDFontFactory.createFont(COSDictionary) line: 116	
> 	PDFontFactory.createFont(COSDictionary, Map) line: 75	
> 	PDResources.getFonts(Map) line: 115	
> 	PDFTextStripper(PDFStreamEngine).processSubStream(PDPage, PDResources, COSStream) line: 243	
> 	PDFTextStripper(PDFStreamEngine).processStream(PDPage, PDResources, COSStream) line: 225	
> 	PDFTextStripper.processPage(PDPage, COSStream) line: 442	
> 	PDFTextStripper.processPages(List<COSObjectable>) line: 366	
> 	PDFTextStripper.writeText(PDDocument, Writer) line: 322	
> 	PDFTextStripper.getText(PDDocument) line: 242	
> I've attached the PDF file and test class I've used for reproducing.  

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira