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

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.2
File Size Uploaded Provenance Actions
khmerpdf-0.1.2.tar.gz 80.8 kB Without provenance Details for khmerpdf-0.1.2.tar.gz

Built distributions (wheels)

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

Download URL khmerpdf-0.1.2.tar.gz
Size 80.8 kB
Tags Source
SHA-256 checksum
How to use checksums
28c5a3a7fe363d9cf386b42c05a2b31f3f505e71dac0af1bcb3853cfce043d99
BLAKE2b-256 checksum
How to use checksums
a46b9afd959d9040ae02739bc6aa32b67d6c50a7899f8a17977d1562eacfe8f0
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.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL khmerpdf-0.1.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 850.6 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a23fb0b894186a718fc452571cefc03701851db6be142b93068d46779ee65096
BLAKE2b-256 checksum
How to use checksums
47689789796b4a571a69ca77d82e949d0ed27efdb853c1dbaf1138bd3c2e3b7e
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.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL khmerpdf-0.1.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 811.4 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e65a47ac5c43c9ec56646d7dc0bc26b0a2e08af7fa5bb173bb1d103b31f848d0
BLAKE2b-256 checksum
How to use checksums
a252d96a2a3a1248654d1bf4dd7acb1d6684b517e70f986c89019597f5ed7caa
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.2-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL khmerpdf-0.1.2-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
96fd83195a7e77b5fd24753f5e6f7a3e2e64e1ceeb71e2fbff4e03aa21195f15
BLAKE2b-256 checksum
How to use checksums
f9113c6165abc022ed2cdf85f19afea6d4f4307c5c922bb90d8c91fbb43e3e86
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.2

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