Skip to main content

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)

Source distribution for turbo-html2pdf 0.3.4
File Size Uploaded
turbo_html2pdf-0.3.4.tar.gz 4.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for turbo-html2pdf 0.3.4
File
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

Release history Release notifications | RSS feed

This release

0.3.4 This release

5 release files

0.3.3

5 release files

0.3.1

5 release files

0.3.0

5 release files

0.2.15

5 release files

0.2.14

5 release files

0.2.13

5 release files

0.2.6

5 release files

0.2.4

5 release files

0.2.3

5 release files

0.2.2

5 release files

0.2.1

5 release files

0.2.0

5 release files

0.1.7

5 release files

0.1.4

5 release files

0.1.3

5 release files

0.1.2

5 release files

0.1.1

5 release files

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