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.39.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.39.0-cp39-abi3-win_amd64.whl (7.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

pyfulgur-0.39.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.39.0-cp39-abi3-musllinux_1_2_aarch64.whl (7.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

pyfulgur-0.39.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.39.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.39.0-cp39-abi3-macosx_11_0_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pyfulgur-0.39.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.39.0.tar.gz.

File metadata

  • Download URL: pyfulgur-0.39.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.39.0.tar.gz
Algorithm Hash digest
SHA256 9b34660d5fb4adc62c98a3ffe1d9983aa8c6beec908db8aea419a44a9f4292d0
MD5 2653e2a26ee31af7568bd3ed74bb0831
BLAKE2b-256 a7798bf43bcedbd9d1cb5ec444f18931f6ed2e9132dfbef31125fe59115eeb74

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pyfulgur-0.39.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.39.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5283e2e4b3536e303d70ac648e933d9787bf53f6690784a1feafa38f044e3191
MD5 ded5b680d777e44cbaf783912ac3079f
BLAKE2b-256 9e2e8f7e1acc9febed9d16b5caed304fce8e784f052d7d7ebd7215794593e88e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.39.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 237a0502635807b6c730d56aa80cd92ff3ad2473b81e5cb49b70c7d5b48ed876
MD5 11aab9dc7b08611167eafb73b7b1e73d
BLAKE2b-256 498161b08fa7909a377039c17ed9db2c96303b366648f6b6817f5feee6bf466b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.39.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7eae41f6636b5a1897ef136f26c7a375d0db5023ecca58e594ef148dfd8174c9
MD5 8d60c4047fd8210a6874f912b3817113
BLAKE2b-256 900cbc47b62f8a5b3da39d61d9da5c39d6e1134bfbc781cdf27f759aa2a44d3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.39.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22c1dde68a50d7c2c34c3bb8d19ec550e45f7bea6964de9b46014dd1c1d2cea2
MD5 e43dda36d8a8d96274007a6ad4607720
BLAKE2b-256 87d52684c2cba498cb9611eb9582a695c6a95904e5d9534f25ca8f5521ceedff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.39.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f2f819ba4e5b6243191111dc81b5946a0c0113596ce58b7e12949c7fe9addd2a
MD5 1c221462d3412afcdba52d8531f30bbf
BLAKE2b-256 1edaff81100348df33f3e08302cdc05f42f5c8de765f6d13b68b71ec69308b05

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.39.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3de53e42c72efa88e4231a88342823e835f0fc8e57681c9fd8163ece94d1969
MD5 e55bbff38484b678400aed1a1653b5f1
BLAKE2b-256 2325d4c86653ce15e6d91caf9d79797f174bc21f3c3550f2c23cabf561476df8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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.39.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.39.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9aa1eca195f18bec7653633e01fee652d63610b8ce8f7404afeb67e8adf5a4e1
MD5 515a75c07e8b8389bcbab6760ef976d1
BLAKE2b-256 da2b35bbfea19813551f4a550c4167f368b142fcf7c589bf0b501a5a4f4047c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfulgur-0.39.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

0.40.0

8 files

This release

0.39.0 This release

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