Skip to main content

pyfulgur

Python bindings for fulgur — an offline, deterministic HTML/CSS to PDF conversion library written in Rust.

Status

Alpha (v0.0.2). Core Engine / AssetBundle / PageSize / Margin / render_html API is available. Batch rendering, sandboxing, and template engine wiring are planned for later releases.

Install

Note: v0.0.2 is an early alpha. Pre-built wheels are not yet published to PyPI; install from source for now.

# From a checkout of the fulgur repository
pip install maturin
maturin develop --release -m crates/pyfulgur/Cargo.toml

Pre-built wheels for manylinux / macOS / Windows will be published in a later release.

Quick start

from pyfulgur import AssetBundle, Engine, PageSize

bundle = AssetBundle()
bundle.add_css("body { font-family: sans-serif; }")

engine = Engine(page_size=PageSize.A4, assets=bundle)
pdf_bytes = engine.render_html("<h1>Hello, world!</h1>")

with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)

Builder style:

engine = (
    Engine.builder()
    .page_size(PageSize.A4)
    .landscape(False)
    .title("My doc")
    .assets(bundle)
    .build()
)
engine.render_html_to_file("<h1>Hi</h1>", "out.pdf")

API surface

  • Engine(**kwargs) / Engine.builder()EngineBuilder
  • Engine.render_html(html: str) -> bytes — render to PDF bytes (releases the GIL)
  • Engine.render_html_to_file(html: str, path: str | os.PathLike) -> None — render to a file
  • AssetBundle: add_css, add_css_file, add_font_file, add_image, add_image_file
  • PageSize: A4, LETTER, A3, custom(w_mm, h_mm), .landscape()
  • Margin: Margin(top, right, bottom, left), Margin.uniform(pt), Margin.symmetric(v, h), Margin.uniform_mm(mm)
  • Exceptions: FileNotFoundError, ValueError, pyfulgur.RenderError

Type stubs

pyfulgur ships PEP 561 type stubs (py.typed + __init__.pyi) so mypy, pyright, and IDEs can type-check call sites against the native API. Docstrings live in the Rust source and are exposed via __doc__ for help(), Jupyter ?, and griffe / mkdocstrings inspection.

Known limitation: blitz parse-error noise on stdout

The underlying blitz-dom parser writes non-fatal html5ever parse errors directly to the process's stdout via println!. These fire for browser-tolerated but technically invalid HTML — documents without a <!DOCTYPE>, missing <html>/<body> wrappers, or structural quirks that browsers silently auto-correct — and show up as ERROR: ... noise in Jupyter notebooks or any environment that captures stdout. The PDF bytes returned by render_html are not affected; only the caller's terminal is polluted.

pyfulgur intentionally does not redirect fd 1 from inside the binding: process-wide fd manipulation in a multi-threaded library context races with concurrent render_html calls from other threads (mixed suppress / non-suppress callers would silently lose stdout during a suppressed window). Correctness and parallelism take priority over cosmetic stdout cleanliness.

If you need clean stdout:

  • Redirect at the caller side with a Python contextlib.redirect_stdout for Python-level writes, or os.dup2 for fd-level writes. This keeps the fd manipulation scoped to your own call site where you can guarantee single-threaded use.
  • Run renders in a subprocess via multiprocessing (each worker has its own fd 1).
  • Use the fulgur CLI (which handles stdout isolation internally) invoked via subprocess.run when cold-start cost is acceptable.

A wrapper-style Python package that shells out to the fulgur CLI (clean stdout, parallel via process isolation, no native build required) is on the roadmap as a complement to this native binding.

Links

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Download files

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

Source Distribution

pyfulgur-0.40.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

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

pyfulgur-0.40.0-cp39-abi3-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_aarch64.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.5 MB view details)

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

pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

pyfulgur-0.40.0-cp39-abi3-macosx_11_0_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pyfulgur-0.40.0-cp39-abi3-macosx_10_12_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file pyfulgur-0.40.0.tar.gz.

File metadata

  • Download URL: pyfulgur-0.40.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pyfulgur-0.40.0.tar.gz
Algorithm Hash digest
SHA256 36fc36fd008b1eaee9e0c01d60b8b291733daf82dc7ed26127fb71155572a059
MD5 f7d5c197a5f5693229ae46c670f7fac3
BLAKE2b-256 69b074be65477b9ef9aaa3682c068ba4663159ba49cdc73501477e50651d3ae5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0.tar.gz:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pyfulgur-0.40.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d650880b868518a5e28014f8a5ccd59a2a90624ac839ee6215ae8d948dc6d6ba
MD5 ab2649a126eaee2b750f2da596aa9161
BLAKE2b-256 9296a7e7419f71d111da1a8aad620910dba07d354665c4fb022f60eafeae316a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-win_amd64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1e840d1a038f9e59aef6e3dfbfa2997cf079045dc3e05809190fd12064613356
MD5 d4a27ab52691775f59b687bc6ce7f7b2
BLAKE2b-256 4c45e65c40b67ccf780ced3ffdc6c572f131fba912309630b514a14074664a8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5a17e63229053a1e2ed9166d00a5f81381fc8176ce2c7c1087c0d5fd62228642
MD5 1f31d4df3e2e66c7a4fa0d0411821d09
BLAKE2b-256 4b3cbe8b484ac6221586f97d473818cf53951257e34f299a5e7691f2bb108650

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-musllinux_1_2_aarch64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6e5df76169554f84323ee0350527b82baf568d13a3c5983a4fbad07e7eb2c6b
MD5 3306e0e08de30fb6a22ad92016dd73e9
BLAKE2b-256 4ac12f09ff60451ae6e60b81186df8cc400bcb778e53d59051fb7500917694c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8da9e0b6939fe0275d56a68c611e7624f2913a81136e144289c2d0c0f5844288
MD5 093744c5da62de15258e24544613cbb7
BLAKE2b-256 c8d6e65393958e35a206f8d45b1928138f58a932381ab1fe75605487912da288

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b63552dbfaec1d5dc281bfcc10191169124ee1980a4f8544d0639f15b20439d6
MD5 5056acd65a10b198cd84dbb483e8599c
BLAKE2b-256 f332c8c6527ea1864d07a2c91f92ed6ef809858eae6d9362d03ed71b6b4b28ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfulgur-0.40.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.40.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f3f472cced6567f4766778b9ce868f7dc06d0c458b3270dc723e1647426a3198
MD5 ecae63c7e2580078f2f7bdca65d5c5d4
BLAKE2b-256 a0174ddc77da807fd49cf4936ae275f9b23e6547db815a2f1e1b191dcfdd65a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.40.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yml on fulgur-rs/fulgur

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.40.0 This release

8 files

0.39.0

8 files

0.38.0

8 files

0.37.0

8 files

0.36.0

8 files

0.35.0

8 files

0.34.0

8 files

0.33.0

8 files

0.32.0

8 files

0.31.0

8 files

0.30.0

8 files

0.29.0

8 files

0.28.0

8 files

0.27.0

8 files

0.26.0

8 files

0.25.0

8 files

0.24.0

8 files

0.23.0

8 files

0.22.0

8 files

0.21.0

8 files

0.20.0

8 files

0.19.0

8 files

0.18.0

8 files

0.17.0

6 files

0.16.0

6 files

0.15.0

6 files

0.14.0

6 files

0.13.0

6 files

0.12.0

6 files

0.11.0

6 files

0.10.0

6 files

0.9.0

6 files

0.8.0

6 files

0.7.0

6 files

0.5.11

6 files

0.5.8

6 files

0.5.6

6 files

0.5.5

6 files

0.5.2

6 files

0.5.1

6 files

0.5.0

6 files

0.0.1

1 file

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