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.

pdftotextការររៀបចំត្រកបខ័ណឌត្ររប់ត្ររង
khpdfការរៀបចំក្របខ័ណ្ឌគ្រប់គ្រង

Three ways to use it

ForStart here
PythonScripts, notebooks, NLP pipelinesPython
Command lineConverting files and whole foldersCommand line
BrowserTrying a PDF without installing anythingTry it

All three run the same Rust engine and give the same result. There is also a Rust library.

In ten seconds

Terminal
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