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.38.0.tar.gz (965.9 kB view details)

Uploaded Source

Built Distributions

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

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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

pyfulgur-0.38.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.38.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.38.0-cp39-abi3-macosx_11_0_arm64.whl (6.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pyfulgur-0.38.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.38.0.tar.gz.

File metadata

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

File hashes

Hashes for pyfulgur-0.38.0.tar.gz
Algorithm Hash digest
SHA256 bd6a2cebd00effc0856457a43aa846449502c5e4699bc2b3879ca25c09f5aab1
MD5 1c2cdbfd478753d6bfee576bdc3707df
BLAKE2b-256 092c89926e97bf3d5e83ff0e5690ed0da856cb09748f9dfbd35f4b6810821efb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyfulgur-0.38.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.38.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8f165b858e9ea3f7d54783964a30ad5cb36bcd41f22aea222785b027b85f71e1
MD5 a0063267c81378b6de883d361a1bc6f8
BLAKE2b-256 452dd4c07cbc510f861b5bdf2d298aee466f5f9c9d65d0d64a188691dc3dbc40

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyfulgur-0.38.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d6111d600c4c14f0497beaaa24443e9b7250dd23fa777ae202b41be77c5e1ee1
MD5 1cae4d327eb5197e093b4332e7a4bc10
BLAKE2b-256 bee242939d946db9a0eb44b77c67744139109f84cdcd4be7aad31684468e2fb7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyfulgur-0.38.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f8581a0333685800985f39955f6b31c5e9d2d65b31aa079dae7d257491a1475d
MD5 d532278744cf6c5c45cf2cd1f6e92a9f
BLAKE2b-256 ce9d1d0379e6bdc1f2341815fb479ae099fdbbd158f0157b8a89de005d3b0ead

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyfulgur-0.38.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72fa6d2daf8f811b263a43b329a175085c8822c07b4bb60f53bde9b99fbf9a4d
MD5 1ab308ec4c8fe134070889eb904c9352
BLAKE2b-256 c4080d12047e55fdfe4f232e749f20c107bc2d0a56c7f1fa4973fd579f430334

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyfulgur-0.38.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4caeca059ab1e27d4ac7a1d4390d3f645069271d6160e8a8030f464273cdffd1
MD5 e7e027c256f71204404bbb013dc16f00
BLAKE2b-256 5a34fef590c3e3b68cce37612cd1bc716138699a2500ae3d621127252b49d576

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyfulgur-0.38.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b811667384cb309f4e446af2cccfa71831934462ee7b6dd337921d56166f8193
MD5 0d00f7a27be899cbd31acd6bd9447d0f
BLAKE2b-256 f80bd4be0c3fa6a2c4d57ca1c146e9fe3223f3fe5f01ad9e3d284c68314f02ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyfulgur-0.38.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 717eb676b01e7f24fafec73bc9cc9aef75d08c0e78660e2419e9f6004f564c86
MD5 2c9b4f547702c75d976a99326e2d87fe
BLAKE2b-256 5cdf63d71004a414a6a0b1b7b9e2c5959aa384e3c0beaf7c5170630c61788156

See more details on using hashes here.

Provenance

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

0.39.0

8 files

This release

0.38.0 This release

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