Python bindings for fulgur — offline HTML/CSS to PDF conversion
Project description
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()→EngineBuilderEngine.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 fileAssetBundle:add_css,add_css_file,add_font_file,add_image,add_image_filePageSize: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
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_stdoutfor Python-level writes, oros.dup2for 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
fulgurCLI (which handles stdout isolation internally) invoked viasubprocess.runwhen 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfulgur-0.10.0.tar.gz.
File metadata
- Download URL: pyfulgur-0.10.0.tar.gz
- Upload date:
- Size: 543.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c4b31ce265a1c0cc1329f625f012c15721a4674f86426ce461fc107dcaed114
|
|
| MD5 |
a005bc6d6ea5005c6700fac86ee327e0
|
|
| BLAKE2b-256 |
ba10ba0d99403063bb59982d08bf4718e6b0813d64cef8cccb7453b145a7c25f
|
Provenance
The following attestation bundles were made for pyfulgur-0.10.0.tar.gz:
Publisher:
release-python.yml on fulgur-rs/fulgur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfulgur-0.10.0.tar.gz -
Subject digest:
4c4b31ce265a1c0cc1329f625f012c15721a4674f86426ce461fc107dcaed114 - Sigstore transparency entry: 1394005803
- Sigstore integration time:
-
Permalink:
fulgur-rs/fulgur@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/fulgur-rs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfulgur-0.10.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: pyfulgur-0.10.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 7.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f4e7283de413cdebbe6a7d1c470d28b23d04dd69b6f2721b52f98be80cb2ade
|
|
| MD5 |
efc5d510fe3031fa4d2eed1b3f3a3ea7
|
|
| BLAKE2b-256 |
9df9929078d872ba0d4e58a6bd7d58511b1633f37ea2c7d49d68fd31392ff0d4
|
Provenance
The following attestation bundles were made for pyfulgur-0.10.0-cp39-abi3-win_amd64.whl:
Publisher:
release-python.yml on fulgur-rs/fulgur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfulgur-0.10.0-cp39-abi3-win_amd64.whl -
Subject digest:
1f4e7283de413cdebbe6a7d1c470d28b23d04dd69b6f2721b52f98be80cb2ade - Sigstore transparency entry: 1394005830
- Sigstore integration time:
-
Permalink:
fulgur-rs/fulgur@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/fulgur-rs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 7.3 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb87df783a93bcbcda67749e2e6ee6500d1efefffad6bd8f4e44c7d5ca0682fc
|
|
| MD5 |
6ddb79fe111a616eba3c218be817935b
|
|
| BLAKE2b-256 |
5ddfd88f156c3764fa9a03790727d883d97be21dfaed240a7856be94265d42da
|
Provenance
The following attestation bundles were made for pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-python.yml on fulgur-rs/fulgur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
eb87df783a93bcbcda67749e2e6ee6500d1efefffad6bd8f4e44c7d5ca0682fc - Sigstore transparency entry: 1394005866
- Sigstore integration time:
-
Permalink:
fulgur-rs/fulgur@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/fulgur-rs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 6.9 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2c64d30c186b7b633666e5f936dcc106cb9e0681261a6430d77c3728eb83a29
|
|
| MD5 |
c018abed775eae519cb6427ffca78cc9
|
|
| BLAKE2b-256 |
9b80319127b2982a6c4fe126c5e3c9205c922f778359a307f2fb0b2db0e60161
|
Provenance
The following attestation bundles were made for pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release-python.yml on fulgur-rs/fulgur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfulgur-0.10.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
b2c64d30c186b7b633666e5f936dcc106cb9e0681261a6430d77c3728eb83a29 - Sigstore transparency entry: 1394005819
- Sigstore integration time:
-
Permalink:
fulgur-rs/fulgur@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/fulgur-rs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfulgur-0.10.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyfulgur-0.10.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d43876e8849cceac252b7e38fdb17ab14e2a7fb9160dcc24e2bdad8864e0d1ba
|
|
| MD5 |
a1e9ce6bf48a3b09892c070a6db7e137
|
|
| BLAKE2b-256 |
d8f983af627062041e29a3d75b4c732b3acfc993cca72e26a1ec2510c8dab536
|
Provenance
The following attestation bundles were made for pyfulgur-0.10.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release-python.yml on fulgur-rs/fulgur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfulgur-0.10.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
d43876e8849cceac252b7e38fdb17ab14e2a7fb9160dcc24e2bdad8864e0d1ba - Sigstore transparency entry: 1394005813
- Sigstore integration time:
-
Permalink:
fulgur-rs/fulgur@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/fulgur-rs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfulgur-0.10.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyfulgur-0.10.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.8 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29fd7d88ea265a1881fb7064199f4dd40f867c5ce25017a40fe616fd9ff8c6b9
|
|
| MD5 |
d34810f10f34e208d34d2623c4dcb042
|
|
| BLAKE2b-256 |
7846d91b333f8227e22beee5b470e1564c78f7678c066e3be46d56a9edee5e15
|
Provenance
The following attestation bundles were made for pyfulgur-0.10.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release-python.yml on fulgur-rs/fulgur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfulgur-0.10.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
29fd7d88ea265a1881fb7064199f4dd40f867c5ce25017a40fe616fd9ff8c6b9 - Sigstore transparency entry: 1394005846
- Sigstore integration time:
-
Permalink:
fulgur-rs/fulgur@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/fulgur-rs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@3d58066483c796ec7843d2ad4bebda99c28f9b96 -
Trigger Event:
release
-
Statement type: