Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.5.0
-
None
Description
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.