Khmer text out of any PDF អក្សរ
Copy Khmer from a PDF and you often get scrambled letters. khpdf reads the fonts inside the file and gives back correct Khmer Unicode, as plain text, Markdown or JSON. Open source, written in Rust.
Real output from public documents. The first box is Poppler's pdftotext; the second is khpdf on the same page.
Try it
Drop a PDF to see its Khmer text. khpdf runs inside this page as WebAssembly.
What it fixes
Each problem below was found in a real Cambodian PDF and has a regression test. See them all with examples.
Wrong labels from Word
/ToUnicodeWord gives each glyph one label, and for glyphs shared by many Khmer words that label is often wrong: the ្រ glyph can read as ត្រ everywhere. khpdf trusts the embedded font instead.
Stripped fonts
Khmer OS · cmap · GSUBFont subsets often lose their tables. khpdf restores them from the Khmer OS glyph layout or from the font's own substitution rules.
Visual glyph order
េ ែ ៃ ្រPDFs store vowels and ្រ in the order they are drawn, before the consonant. khpdf puts them back in Unicode order.
Limon legacy fonts
LimonS1 · LmnTTOlder documents type Khmer with Latin letters in Limon fonts. khpdf decodes them, even when one word is split across font copies.
Sideways pages
text directionLandscape diagrams stored sideways are read along the text, so lines stay whole instead of falling apart.
Tables and layout
Markdown · text · JSONHeadings, paragraphs, lists and tables whose columns line up, with notes on pages that need OCR.
Next steps
- Your first PDF: convert a PDF, save the result and read the summary.
- Python and command line: every option, for one file or a whole folder.
- How it works: the steps from PDF bytes to clean Unicode text.