Your first PDF
Convert a PDF, save the result, and see what the summary tells you.
- Print it to the terminalRun khpdf on any PDF with Khmer text. The result is Markdown, printed straight to your terminal.
khpdf report.pdf
- Save itGive an output file with
-o. The file name picks the format:.mdfor Markdown,.txtfor plain text,.jsonfor structured data.khpdf report.pdf -o report.txt
- Read the summaryWhen you save to a file, khpdf prints one line per PDF: where it went, how many pages it read and how much Khmer came out.
✓ report.pdf → report.txt (3 pages, 3,085 Khmer characters)
- Check for scansIf a PDF is only pictures of text, khpdf says so instead of giving you nothing:
✓ notice.pdf → notice.txt (2 pages, 0 Khmer characters) note: this PDF is scanned images with no text layer; it needs OCR, which khpdf does not do
- Convert a whole folderPoint khpdf at a folder and give it an output folder. Add
-rto include subfolders.khpdf documents/ -o converted/ -r
The same in Python
import khpdf
text = khpdf.extract("report.pdf")
print(text[:200])Next: The output explains what each format contains.