Hello, in pdfbox 3.0.0-alpha3 I am encountering the following error:
java.lang.NullPointerException: Cannot read the array length because
"this.glyphIdToCharacterCode" is null
org.apache.fontbox.ttf.CmapSubtable.getCharCode(CmapSubtable.java:638)
org.apache.fontbox.ttf.CmapSubtable.getCharCodes(CmapSubtable.java:655)
org.apache.pdfbox.pdmodel.font.PDType0Font.toUnicode(PDType0Font.java:546)…
This is thrown after the following code executes:
while (currentPosition < bytes.size && currentCharacterBytes++ <
maxEncodingBytes) {
potentialCode =
potentialCode.shl(8).or(bytes[currentPosition++].toInt().and(0xFF))
val potentialRepresentation: String
potentialRepresentation = font.toUnicode(potentialCode) ?: continue //
Thrown Here
unicodeRepresentation.append(potentialRepresentation)
codes.add(potentialCode)
currentCharacterBytes = 0
potentialCode = 0
}
Unfortunately, the pdf that caused this is not available, this error was
discovered in review of the logs. From the exception itself, it would seem that
the glyphIdToCharacterCode array is not being initialized. I’ve tried to use a
lot of different glyphs/fonts/emojis to try and recreate the exception, but
they were unsuccessful.
Best Regards,
Charles