zpdf
High-performance PDF text extraction powered by Zig. ~4x faster than MuPDF on large documents.
Install
pip install zpdf
Usage
from zpdf import Document
with Document("paper.pdf") as doc:
print(doc.page_count)
# Extract all text (reading order)
text = doc.extract_all()
# Extract single page
page_text = doc.extract_page(0)
# Extract as markdown
md = doc.extract_all_markdown()
# Get text with bounding boxes
spans = doc.extract_bounds(0)
for span in spans:
print(f"{span.text} at ({span.x0}, {span.y0})")
From bytes
with open("doc.pdf", "rb") as f:
data = f.read()
with Document(data) as doc:
text = doc.extract_all()
Benchmark
Text extraction on Apple M4 Pro:
| Document | Pages | zpdf | MuPDF | Speedup |
|---|---|---|---|---|
| Intel SDM | 5,252 | 582ms | 2,152ms | 3.7x |
| Pandas Docs | 3,743 | 640ms | 1,130ms | 1.8x |
| C++ Standard | 2,134 | 438ms | 1,007ms | 2.3x |
| PDF Reference | 1,310 | 236ms | 1,481ms | 6.3x |
License
CC0-1.0
Metadata
Release files for zpdf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zpdf-0.1.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
Release files / zpdf-0.1.0-py3-none-macosx_11_0_arm64.whl
| Download URL | zpdf-0.1.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 168.2 kB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4845caa1a0f51a05ec8b9fd12dffe5af3ad10982d90b220226fc58bbbe72fad1
|
|
BLAKE2b-256 checksum How to use checksums |
919c6710b30d6969f74d46d2ff57bdb33f7cf10080a9acac4bffed71bef02ecd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|