Your first PDF

Convert a PDF, save the result, and see what the summary tells you.

  1. Print it to the terminalRun khpdf on any PDF with Khmer text. The result is Markdown, printed straight to your terminal.
    Terminal
    khpdf report.pdf
  2. Save itGive an output file with -o. The file name picks the format: .md for Markdown, .txt for plain text, .json for structured data.
    Terminal
    khpdf report.pdf -o report.txt
  3. 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.
    Output
    ✓ report.pdf → report.txt  (3 pages, 3,085 Khmer characters)
  4. Check for scansIf a PDF is only pictures of text, khpdf says so instead of giving you nothing:
    Output
    ✓ 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
  5. Convert a whole folderPoint khpdf at a folder and give it an output folder. Add -r to include subfolders.
    Terminal
    khpdf documents/ -o converted/ -r

The same in Python

Python
import khpdf

text = khpdf.extract("report.pdf")
print(text[:200])

Next: The output explains what each format contains.