Type3 font without ToUnicode: whole page dropped (kids: []), 'glyph can not be mapped to Unicode' (2.4.7)
Bug
A page whose only font is a Type3 font with a /Differences encoding and no /ToUnicode produces no elements at all in the JSON output (kids: []), with one WARNING: The glyph can not be mapped to Unicode per glyph. Every content-safety setting gives the same result (--content-safety-off all, --content-safety-off hidden-text, default). pdfium extracts the text from the same file (the character codes are the text; the glyph names are arbitrary), so the text layer is usable.
We hit this on three real one-page client PDFs (single Type3 font, 1,685–3,283 characters per page for pdfium, 0 elements for ODL, 8,076 warnings in total). They cannot be shared; the file below reproduces it.
Environment
opendataloader-pdf 2.4.7 (PyPI wheel, bundled JAR), OpenJDK 17.0.15, Linux.
java -Djava.awt.headless=true -jar opendataloader-pdf-cli.jar --format json --image-output off --hybrid off -o out in
Minimal file (save as type3.pdf, 1 KB; two glyphs drawn as rectangles, text abab baba)
%PDF-1.4
1 0 obj
<< /Type /Catalog /Pages 2 0 R >>
endobj
2 0 obj
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /T3 5 0 R >> >> >>
endobj
4 0 obj
<< /Length 40 >>
stream
BT /T3 24 Tf 72 700 Td (abab baba) Tj ET
endstream
endobj
5 0 obj
<< /Type /Font /Subtype /Type3 /FontBBox [0 0 750 750] /FontMatrix [0.001 0 0 0.001 0 0] /CharProcs 6 0 R /Encoding << /Type /Encoding /Differences [97 /square 98 /triangle] >> /FirstChar 97 /LastChar 98 /Widths [1000 1000] /Resources << >> >>
endobj
6 0 obj
<< /square 7 0 R /triangle 8 0 R >>
endobj
7 0 obj
<< /Length 38 >>
stream
1000 0 0 0 750 750 d1 0 0 375 375 re f
endstream
endobj
8 0 obj
<< /Length 40 >>
stream
1000 0 0 0 750 750 d1 0 375 375 375 re f
endstream
endobj
xref
0 9
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000241 00000 n
0000000331 00000 n
0000000590 00000 n
0000000641 00000 n
0000000729 00000 n
trailer
<< /Size 9 /Root 1 0 R >>
startxref
819
%%EOFResult: JSON root has "kids": []; log shows 9 x The glyph can not be mapped to Unicode. pypdfium2 returns 9 characters, abab baba.
Expected
Text from a Type3 font without ToUnicode should fall back to the character codes (or the encoding's glyph names when they are standard names) instead of being dropped, or at least the page should not come out empty when the codes are printable.
Source: opendataloader-project/opendataloader-pdf