CID fonts store glyphs by number rather than by character, and the PDF needs a ToUnicode map, called a CMap, to turn those numbers back into text. When the map is missing or incomplete, extraction returns blank spaces or wrong characters even though the page looks fine.
What you need
- Python with pypdf installed
- A PDF that uses CID fonts, such as a CJK document
- A terminal
Step 1: Extract the text with pypdf
Use pypdf to extract the text of the PDF and save it to a plain-text file.
Step 2: Look for missing or garbled characters
Read the extracted text and look for blank gaps where characters should be, replacement characters, or characters that do not match the words visible on the page.
Step 3: Confirm the cause and choose a fix
If the gaps line up with text set in a CID font, the encoding map is the problem. Re-export the PDF with a complete ToUnicode map, or OCR the affected pages instead of extracting their text.
Worked example: synthetic CID extraction check on a bilingual report
The table below is a synthetic example. It shows the expected result of the extraction check; no extraction was run.
| Page | Extracted text | Verdict |
|---|---|---|
| Page 1 | Clean English text | Fine |
| Page 3 | Gaps where Chinese characters sit | CID map incomplete |
| Page 5 | Clean English text | Fine |
| Total | 3 pages | 1 page needs OCR or re-export |
Expected result (UNTESTED). the English pages extract cleanly, but page 3 shows gaps where the Chinese characters should be, so its CID encoding map is incomplete and the page needs OCR or a re-export. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- A missing ToUnicode map does not mean the page is broken for reading; it only breaks extraction, copying, and search.
- Some CID fonts extract correctly for Latin characters and fail only for CJK characters.
- OCR of the affected pages can introduce its own errors, so proofread the result.
