turbo-html2pdf (Python)
Native HTML/CSS-to-PDF engine with a Jinja-compatible templating DSL. PyO3
binding over the turbo-pdf Rust core; mirrors the Node turbo-html2pdf
package 1:1.
import turbo_html2pdf as t
# Compile once, render many times.
prog = t.compile("<p>Hello {{ data.name }}</p>")
pdf = prog.render(data={"name": "world"}) # -> bytes, starts with b"%PDF"
# Warm fonts once, reuse the handle across renders.
fonts = t.Fonts.load([open(p, "rb").read() for p in font_paths])
pdf = prog.render(
data={"name": "world"},
css="body { font-family: font0 }",
fonts=fonts,
)
# One-shot: compile + render in a single call.
pdf = t.render("<p>{{ data.x }}</p>", data={"x": 1})
# Inspect non-fatal lints + page count.
pdf, diagnostics, page_count = prog.render_full(data={"name": "world"})
Fatal compile/render faults raise TurboPdfError carrying .code (a stable
string such as "TemplateSyntax") and .span ({"line", "col", "byte_offset"}).
Non-fatal lints are returned by render_full, never raised.
API
| Surface | Signature |
|---|---|
compile(template_html, opts=None) |
-> Program |
Program.render(data=None, css="", fonts=None, images=None, meta=None, now=None) |
-> bytes |
Program.render_full(...) |
-> (bytes, list[dict], int) |
Program.has_header() / Program.has_footer() |
-> bool |
render(template_html, ...) |
one-shot -> bytes |
Fonts.load([bytes, ...]) |
warm registry -> Fonts |
Building from source
pip install maturin
maturin develop --manifest-path crates/turbo-pdf-py/Cargo.toml
python -m pytest crates/turbo-pdf-py/tests
Metadata
Release files for turbo-html2pdf 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| turbo_html2pdf-0.3.4.tar.gz | 4.1 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| turbo_html2pdf-0.3.4-cp38-abi3-win_amd64.whl | CPython 3.8 | abi3 | Windows x86-64 | Details |
| turbo_html2pdf-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| turbo_html2pdf-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.8 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| turbo_html2pdf-0.3.4-cp38-abi3-macosx_11_0_arm64.whl | CPython 3.8 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 28.5 MB
Release files / turbo_html2pdf-0.3.4.tar.gz
| Download URL | turbo_html2pdf-0.3.4.tar.gz |
|---|---|
| Size | 4.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69c5e87af09d664ef710af5cdc8cc37597af9eac524d4940af0e226abfe293ae
|
|
BLAKE2b-256 checksum How to use checksums |
31349eb87cf067a2f03f00420a5e5ec1c339f2713a3cdf329fffe17555edcb46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / turbo_html2pdf-0.3.4-cp38-abi3-win_amd64.whl
| Download URL | turbo_html2pdf-0.3.4-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
672c45735bbef90b7d3460b45179e9f4551cd68d7c8a1701c4a7f522480c0b08
|
|
BLAKE2b-256 checksum How to use checksums |
15c0f3149ed4f9387f480a3fc0f51cde376ae4b3be2a1f342e71ffbf7b3b2ae0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / turbo_html2pdf-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | turbo_html2pdf-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.2 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3d7afaf8fd9ba2046f898cc17a799e968408f89fd1f6b02d018f6caad516c84b
|
|
BLAKE2b-256 checksum How to use checksums |
92d3bdf3dd575b72b8551af4704fc67e6b21ad12b4e8c795cce1dd9f4ed9d986
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / turbo_html2pdf-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | turbo_html2pdf-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.2 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
e168a45c92e183b0d56ff30ed29220735d566396dc1d0ff74e7bf5cb8212a1c7
|
|
BLAKE2b-256 checksum How to use checksums |
9c479ff329b0935fda3cceef7a3ff340226f7928f7236d7ec5e44e8cc8d526b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / turbo_html2pdf-0.3.4-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | turbo_html2pdf-0.3.4-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ebed42cd87fd5b62792a71cb2b196654d705b2823446b2b23df9bbf4dbc53bbc
|
|
BLAKE2b-256 checksum How to use checksums |
e3747c5c96fea271f45438317967a27f69bc4cb93855b2bc41058f570af974bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|