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

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.3
File Size Uploaded
turbo_html2pdf-0.3.3.tar.gz 4.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for turbo-html2pdf 0.3.3
File
turbo_html2pdf-0.3.3-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
turbo_html2pdf-0.3.3-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.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
turbo_html2pdf-0.3.3-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 28.4 MB

Release files / turbo_html2pdf-0.3.3.tar.gz

Download URL turbo_html2pdf-0.3.3.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
4e42e630ac6795e1e5c1f3cbda5f3c0c1a37bad48aadd03899ea2f9cbe11b361
BLAKE2b-256 checksum
How to use checksums
81f409c908b71949e2af5a15a992aff761d4e847293e0a850af4440a4c0e15a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / turbo_html2pdf-0.3.3-cp38-abi3-win_amd64.whl

Download URL turbo_html2pdf-0.3.3-cp38-abi3-win_amd64.whl
Size 5.9 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a49afc0e149ec258440b33830d9a325ff036c8d4f3184964546269a97d109d56
BLAKE2b-256 checksum
How to use checksums
0b2d06f436370f0ccbcc8df3c3fdff39b84bc68d5bf4cbfe9609eca9f6051349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / turbo_html2pdf-0.3.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL turbo_html2pdf-0.3.3-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
710dc82785dc28bf033bb89991fe7699b03d187f2b0467195a719dfe7c0e314a
BLAKE2b-256 checksum
How to use checksums
9283dd616a7edf9aea11371e687f39195cb409ce75c8087d67ee4afbb61698a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / turbo_html2pdf-0.3.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL turbo_html2pdf-0.3.3-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
ae0bc61fafd47250719c7a5008f85916eabc45df3f439a00e4969769622e6873
BLAKE2b-256 checksum
How to use checksums
c4b88e48c8bc4e52ec39e83fb14c74a6b4d5ebdff56f4814dcd37236beeefb41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / turbo_html2pdf-0.3.3-cp38-abi3-macosx_11_0_arm64.whl

Download URL turbo_html2pdf-0.3.3-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
f20e1278cbff3f6e654e3e69b78124ddddc4f6697fb8c87189fdbcd625572627
BLAKE2b-256 checksum
How to use checksums
6ae06d48204500e6569202548aacc0be9648e25f3843774143cc699213cdd6e1
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.3 This release

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