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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turbo_html2pdf-0.2.15.tar.gz (4.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

turbo_html2pdf-0.2.15-cp38-abi3-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.8+Windows x86-64

turbo_html2pdf-0.2.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

turbo_html2pdf-0.2.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

turbo_html2pdf-0.2.15-cp38-abi3-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file turbo_html2pdf-0.2.15.tar.gz.

File metadata

  • Download URL: turbo_html2pdf-0.2.15.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for turbo_html2pdf-0.2.15.tar.gz
Algorithm Hash digest
SHA256 7380e8e5e250ef8388dc32d9a2f0c713d43080fd9caa9888df15945af86d659d
MD5 70aa39efeeba4e2e3fff52f48b18e22f
BLAKE2b-256 e5f68d81b99b3c339359e37f4ab7c951d1976e64902eae38b21070c2580bdfd0

See more details on using hashes here.

File details

Details for the file turbo_html2pdf-0.2.15-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for turbo_html2pdf-0.2.15-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a484f45496fe1ebe86133ca793238dc9439be90d1af5abc711f0b98918dfc8a3
MD5 e92ad5536f516c385b917f481e9330e0
BLAKE2b-256 0e7e141951b9b6ae4d97ac3f181cc530d6ae26d7620fa317a61227bcee7136d9

See more details on using hashes here.

File details

Details for the file turbo_html2pdf-0.2.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for turbo_html2pdf-0.2.15-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92c56a32b444fbd63224b1f37644fc5c0e175306e9a55756455d92f53cf10d2a
MD5 baa7e8b7cdca32e9584348726602fa1c
BLAKE2b-256 805072f63347170df1b7477173183bdd9563519acd683bf5e86ca2b784cde0cd

See more details on using hashes here.

File details

Details for the file turbo_html2pdf-0.2.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for turbo_html2pdf-0.2.15-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b34947da488f113cbeb5308b5350eb48c20abdce1949ee8f21c8f128121dfd96
MD5 4b61ccbe777bc2f910f13d98383670d0
BLAKE2b-256 697552d08d3b251431ca8d5592d6d9fe817e4ce70e333cb192b47755f2a4d69d

See more details on using hashes here.

File details

Details for the file turbo_html2pdf-0.2.15-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for turbo_html2pdf-0.2.15-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dcc40bc61eb4034c9a19b8896c4a4563bbd1393118a18860c421ddd34b6e137
MD5 6172db5f7ff9fd4c1209c6544160059c
BLAKE2b-256 172dd5d3f75bd7a5fc2c3be3eff4f38d5cb90c7af3aeedaa60c19116a06f4cf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page