Troubleshooting
When a PDF comes out wrong, find out why in three steps.
No text at all
If the summary says 0 Khmer characters and notes that the PDF is scanned, the file is pictures of text. khpdf can't read it; it needs OCR.
Look at the fonts
khpdf adb-book.pdf --pages 4 --inspect-fonts
Page 4 (595x842, needs_ocr=false): - F1 | BaseFont=FCGKGL+HelveticaNeue-Roman | Subtype=Type1 | Enc=WinAnsiEncoding | ToUnicode=false | Embedded=true | Legacy=- - TT6 | BaseFont=FCFOAG+LimonS1 | Subtype=TrueType | Enc=WinAnsiEncoding | ToUnicode=false | Embedded=true | Legacy=limon ! warning: 13 overprinted duplicate text fragment(s) (shadow/fake-bold) dropped.
- BaseFont: the font's name. Khmer OS, Limon (
Legacy=limon) and fonts that kept their tables work best. - Embedded=false: the font isn't in the file, so khpdf has only the PDF's labels to go on.
- Warnings (lines starting with
!) say what khpdf noticed: here, text drawn twice for a shadow effect was dropped. Others report turned pages and fonts with no mapping.
Look at the raw fragments
For a close look, print every fragment khpdf extracted, with its position, size, font and how each letter was recovered:
KHPDF_DEBUG_SPANS=1 khpdf report.pdf --pages 3 > /dev/null
--no-normalize shows the text before Khmer reordering, which tells you whether a problem is in the letters themselves or in their order.
Report it
Open an issue on GitHub with a link to the PDF (or one page of it), the page number, what you expected and what you got. Every fix so far started from a real document like yours.