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.3

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.3
File Size Uploaded Provenance Actions
khmerpdf-0.1.3.tar.gz 123.7 kB Without provenance Details for khmerpdf-0.1.3.tar.gz

Built distributions (wheels)

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

Total release size: 4.4 MB

Release files / khmerpdf-0.1.3.tar.gz

Download URL khmerpdf-0.1.3.tar.gz
Size 123.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7b57e6524e6d89f7598ba9464ee28ef1e8fdff0a4375d70aa7d6efa0334080ea
BLAKE2b-256 checksum
How to use checksums
01614bf8da78b73b3503af5cd75f71e93bb5ac513e2252e2ae2a07df469366e6
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.3-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL khmerpdf-0.1.3-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.1 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
181e92c8ec88ac7d2dfd6ce38fe1d19301d34c709c31613de8844b691c67c60e
BLAKE2b-256 checksum
How to use checksums
c46c23a9dd66c83b8f114e50a39682cd78ce2063ca3cbaa683f2c27d556f2f8a
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.3-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL khmerpdf-0.1.3-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.0 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b100c2be82eec795e30e82a6e30e375ac43f6a162f89b9a78aad3bce71d3d8e3
BLAKE2b-256 checksum
How to use checksums
7dcacbb683905891db46da80a7cc1633678b0ffc49c50657c9b5ecde4b93c073
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.3-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL khmerpdf-0.1.3-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 2.1 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
200bb757a1e058a41ea2395090e8eca630214ab364a10d230e480ec5d890d853
BLAKE2b-256 checksum
How to use checksums
827e4941fe86cceca7b756895a549c0831a07e6e65c100c7808ab75a82a431bf
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.3

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