Hi,
Why are you using 3.0.0-alpha3 from 2022-06-17 while the released
version is 3.0.3 from 2024-08-09? Please retry with 3.0.3, it looks like
that bug was fixed two years ago in PDFBOX-5465.
Tilman
On 19.08.2024 18:39, Charles Harris wrote:
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