Skip to main content

khmerpdf (អក្សរ)

Clean Khmer text out of PDFs that copy-paste mangles. khpdf reads the fonts inside a PDF and gives back correct Khmer Unicode as plain text, Markdown or JSON. The engine is written in Rust; this package gives you it as a Python library and a khpdf command.

pip install khmerpdf
Same page, two tools Standard extraction (pdftotext) khpdf
World Bank 2016 (Word) ការររៀបចំត្រកបខ័ណឌត្ររប់ត្ររង ការរៀបចំក្របខ័ណ្ឌគ្រប់គ្រង
UNDP 2024 (InDesign) កាារអភិិវឌ្ឍឍមនុុស្សស ការអភិវឌ្ឍមនុស្ស
ILO manual (Limon font) esckþIEføgGMNrKuN សេចក្តីថ្លែងអំណរគុណ

Python

import khpdf

text = khpdf.extract("report.pdf")                        # plain text
md = khpdf.extract("report.pdf", format="markdown")       # headings, lists, tables
text = khpdf.extract(pdf_bytes, pages=range(1, 4))        # bytes work too

doc = khpdf.extract_document("report.pdf")                # structured
for page in doc["pages"]:
    if page["needs_ocr"]:
        print("page", page["number"], "is a scan")

The package is installed as khmerpdf and imported as khpdf.

Command line

khpdf report.pdf                 # Markdown in the terminal
khpdf report.pdf -o report.txt   # the format follows the file name (.md, .txt, .json)
khpdf docs/ -o out/ -r           # a whole folder
khpdf --help

What it works on

PDFs with a text layer (made on a computer, not scanned): Word with Khmer OS fonts, Limon legacy fonts, InDesign with complete fonts, tables and sideways pages. Scanned PDFs are detected and reported as needing OCR; khpdf does no OCR.

Try it in your browser, read how it works, or report a PDF that comes out wrong: moriartyputh.github.io/khpdf · github.com/MoriartyPuth/khpdf

Apache-2.0.

Metadata

Release files for khmerpdf 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for khmerpdf 0.1.1
File Size Uploaded Provenance Actions
khmerpdf-0.1.1.tar.gz 76.6 kB Without provenance Details for khmerpdf-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for khmerpdf 0.1.1
File Interpreter ABI Platform Actions
khmerpdf-0.1.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for khmerpdf-0.1.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
khmerpdf-0.1.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for khmerpdf-0.1.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
khmerpdf-0.1.1-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64 Details for khmerpdf-0.1.1-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 3.4 MB

Release files / khmerpdf-0.1.1.tar.gz

Download URL khmerpdf-0.1.1.tar.gz
Size 76.6 kB
Tags Source
SHA-256 checksum
How to use checksums
48c144fd7246a34c5c35abf0c477c2764af009e86d1581dc003d345c2a2c92c5
BLAKE2b-256 checksum
How to use checksums
3e5c1510ba7b6b81db8865c71fce06d69675f7b0365edf2e3cdb25057b8dc7ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / khmerpdf-0.1.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL khmerpdf-0.1.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 842.4 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
11210ebfef80c5722ccd8c9078e010b5ddf91d0fe8b703ae8a16e5af12a4bdcd
BLAKE2b-256 checksum
How to use checksums
42ef0ddd9de300550d69e9a3aed3443043192cd9cf2348df53d12b4a1c573dbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / khmerpdf-0.1.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL khmerpdf-0.1.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 804.3 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
04c86ce8881a4f96bb1be2ce192461cd8f458bd9472091aa317a2e5984ef39da
BLAKE2b-256 checksum
How to use checksums
9d6683b5887cd3f20a8b26c2333c68d79a5b489f816e5f505bd5f658417b1198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / khmerpdf-0.1.1-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL khmerpdf-0.1.1-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f96d99e651c0a24d881a06b1a3f6fc4bc1a064e3446b0549ddc07bc88c0d1656
BLAKE2b-256 checksum
How to use checksums
c260842dca95d83b0a91037e58a782f9dd838fba14ccbab88f537c335dab2291
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for khmerpdf 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page