Native HTML-to-PDF engine (no Chromium, no headless browser). Python bindings.
Project description
pdfox (Python)
Native HTML-to-PDF rendering for Python — no Chromium, no headless browser, no
external binary. A thin PyO3 wrapper over the Rust
pdfox-core engine.
Install
pip install pdfox
Wheels are abi3 (abi3-py38), so a single wheel per platform works on CPython
3.8 and newer.
Usage
import pdfox
# Simplest: HTML string in, PDF bytes out.
pdf: bytes = pdfox.render_html("<h1>Hello</h1>")
# Resolve relative <img>/<link> paths against a directory.
pdf = pdfox.render_html(html, base_dir="./assets")
# Full control — returns an object with .pdf and .diagnostics.
result = pdfox.render(
html,
base_dir="./assets",
allow_remote=True,
deny_list=["internal.corp"],
pdf_a=True,
template_vars={"customer": "Acme Inc."},
)
result.pdf # bytes
result.diagnostics # list[Diagnostic]
result.has_errors() # bool
# Convenience: write straight to a file.
pdfox.render_to_file(html, "out.pdf", base_dir="./assets")
Diagnostics
render() never raises for a missing asset or an unsupported CSS feature — it
degrades gracefully and records a Diagnostic:
for d in result.diagnostics:
print(d.severity, d.kind, d.url, "—", d.reason)
kind ∈ {"image", "font", "stylesheet", "css_feature"};
severity ∈ {"warning", "error"}.
Genuinely broken input raises a pdfox.PdfoxError subclass
(ParseError, LayoutError, EmissionError, FontError, ImageError,
IoError).
Concurrency
render() and render_html() release the GIL while rendering (the work is
pure-Rust and CPU-bound, ~70 ms for a typical page), so they parallelise across
threads. In async frameworks, call them from a thread pool:
pdf = await loop.run_in_executor(None, pdfox.render_html, html)
Develop
# From bindings/python/
pip install maturin pytest
maturin develop # builds the extension into the active venv
pytest # runs tests/
On a just-released CPython where the pinned PyO3 has no version table yet, set
PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1before building.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdfox-0.1.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: pdfox-0.1.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 8.1 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a07df67a75faa0143dfff688f841ab12147414d9d0f1436607c3bfca5da77808
|
|
| MD5 |
0850d3043fc88adbd9e9bd8efe24ec4e
|
|
| BLAKE2b-256 |
09e9f712a478f94c9ececd33bd63e6fb28fe4f6b98ddaab66f7bae32c2c6c0a5
|
Provenance
The following attestation bundles were made for pdfox-0.1.0-cp38-abi3-win_amd64.whl:
Publisher:
python.yml on sauravrao637/pdfox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfox-0.1.0-cp38-abi3-win_amd64.whl -
Subject digest:
a07df67a75faa0143dfff688f841ab12147414d9d0f1436607c3bfca5da77808 - Sigstore transparency entry: 1676635845
- Sigstore integration time:
-
Permalink:
sauravrao637/pdfox@fb86e619c11c34f87cf8235273da6b8f6502a3be -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/sauravrao637
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@fb86e619c11c34f87cf8235273da6b8f6502a3be -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdfox-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pdfox-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 8.8 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b97735bdab4ff51aa5ba9d13460854cdcf6f37373d7e6040f3f666709aa899a
|
|
| MD5 |
d392d6f0a167ff0465d21bd98f430061
|
|
| BLAKE2b-256 |
0c43b9434f1c14143702fc2e17abb4ca230b38ff55797974ba21ad009120fd50
|
Provenance
The following attestation bundles were made for pdfox-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python.yml on sauravrao637/pdfox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfox-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
8b97735bdab4ff51aa5ba9d13460854cdcf6f37373d7e6040f3f666709aa899a - Sigstore transparency entry: 1676635857
- Sigstore integration time:
-
Permalink:
sauravrao637/pdfox@fb86e619c11c34f87cf8235273da6b8f6502a3be -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/sauravrao637
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@fb86e619c11c34f87cf8235273da6b8f6502a3be -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdfox-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pdfox-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3a12e20ede4d1648c6d774b4d5fb3a5ead4624b90aa24f8df6cef5c1f73b269
|
|
| MD5 |
0285ca9969957c965c8be64d318f8ef0
|
|
| BLAKE2b-256 |
4467b042690567d908684bfd3beb63316b057da7fc12173199a479c72f02908e
|
Provenance
The following attestation bundles were made for pdfox-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
python.yml on sauravrao637/pdfox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfox-0.1.0-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
d3a12e20ede4d1648c6d774b4d5fb3a5ead4624b90aa24f8df6cef5c1f73b269 - Sigstore transparency entry: 1676635883
- Sigstore integration time:
-
Permalink:
sauravrao637/pdfox@fb86e619c11c34f87cf8235273da6b8f6502a3be -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/sauravrao637
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@fb86e619c11c34f87cf8235273da6b8f6502a3be -
Trigger Event:
push
-
Statement type: