Hello, we are using pdfbox version 2.0.28 (awesome library, thanks for that!) and recently we observed an issue (attached txt). Unfortunately I do not have the pdf (as this issue happens before the document was saved, so we do not have the document). However looking at the CmapSubtable.java even in the latest code (as well as 2.0.28 version), it seems like the condition is not safe:
private int getCharCode(int gid) { if (gid < 0 || glyphIdToCharacterCode == null || gid >= glyphIdToCharacterCode.length) { return -1; } return glyphIdToCharacterCode[gid]; } Exception and the code as well suggests that even if the glyphIdToCharacterCode is null, it's still possible that glyphIdToCharacerCode.length gets evaluated. What do you think please? Best Regards, Michal Stefan
java.lang.NullPointerException: Cannot read the array length because "this.glyphIdToCharacterCode" is null at org.apache.fontbox.ttf.CmapSubtable.getCharCode(CmapSubtable.java:669) at org.apache.fontbox.ttf.CmapSubtable.getCharCodes(CmapSubtable.java:686) at org.apache.pdfbox.pdmodel.font.PDType0Font.toUnicode(PDType0Font.java:533) at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:838) at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:776) at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextStrings(PDFStreamEngine.java:681) at org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted.process(ShowTextAdjusted.java:53) at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:966) at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:541) at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:516) at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:155) at org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:155) at org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:363) at org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:291) at org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:238) at org.apache.pdfbox.text.PDFTextStripper.getText(PDFTextStripper.java:202)
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org