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

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.0
File Size Uploaded Provenance Actions
khmerpdf-0.1.0.tar.gz 75.0 kB Without provenance Details for khmerpdf-0.1.0.tar.gz

Built distributions (wheels)

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

Total release size: 3.3 MB

Release files / khmerpdf-0.1.0.tar.gz

Download URL khmerpdf-0.1.0.tar.gz
Size 75.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6a460e06351fe64e8f988af94a5e4757ec8dad96cc41333280a7f1773ee93f3d
BLAKE2b-256 checksum
How to use checksums
64240086b777b55bc736638ce8dbee71ffe2dce128b1fa41b3d6466827f63ade
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.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL khmerpdf-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 833.6 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2eced123dc3bf82bc3961a4b2a5c0507c6f9c2d928eb33768f20c4224f1ef63d
BLAKE2b-256 checksum
How to use checksums
4b1c99854644c17db09e77de6595b393d097a332df3f07327a92b311e2960ad9
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.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL khmerpdf-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 795.2 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
76bc911950a86a5d76437d5459613088510ac9bfaaab45c6ca5f972ef6d87c66
BLAKE2b-256 checksum
How to use checksums
9f82c8d141b8f2434ac59669ddae34fb5c23a70075804ed1075a96f4452ecaa8
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.0-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL khmerpdf-0.1.0-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 1.6 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
78fa0bfcf6cb21331555b17236b94e6eb746c2874a755cd8abf01db38f367244
BLAKE2b-256 checksum
How to use checksums
11de115fbdcde91c49754c6f817d0cf4c2b53be4c776b76457f8c28e10b2597f
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.0

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