Introduction
khpdf turns Khmer PDFs into clean, correct Unicode text, even when copy-paste gives you scrambled letters.
Copy Khmer out of a PDF and you often get something like ការររៀបចំត្រកបខ័ណឌ instead of ការរៀបចំក្របខ័ណ្ឌ. The page looks fine; the text behind it is wrong. khpdf (អក្សរ, "letters, script") reads the fonts embedded in the PDF to work out what each glyph really is, puts the letters back in Unicode order, and keeps the layout: headings, paragraphs, lists and tables.
Three ways to use it
| For | Start here | |
|---|---|---|
| Python | Scripts, notebooks, NLP pipelines | Python |
| Command line | Converting files and whole folders | Command line |
| Browser | Trying a PDF without installing anything | Try it |
All three run the same Rust engine and give the same result. There is also a Rust library.
In ten seconds
pip install khmerpdf khpdf report.pdf -o report.txt
What it can and cannot read
khpdf reads PDFs that have a text layer: documents made on a computer and exported or printed to PDF. Word and InDesign documents, older Limon-font documents, tables and sideways pages all work. Scanned PDFs are only pictures of text; khpdf detects them and tells you they need OCR, which it does not do. See What it works on.
Where next
- Install it with pip or Cargo.
- Your first PDF: convert one and read the summary.
- Problems khpdf fixes: what goes wrong in Khmer PDFs, with real before-and-after examples.