Skip to main content

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()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

Links

License

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

Project details


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.5.0.tar.gz (393.1 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.5.0-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

pyfulgur-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.1 MB view details)

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

pyfulgur-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

pyfulgur-0.5.0-cp39-abi3-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pyfulgur-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pyfulgur-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f22a5e78ecc0e6a090991907aacc96e2b643a67ebfd975aefc626285dbd52ea4
MD5 e180bf85604a50d599417e156b00d0f2
BLAKE2b-256 4143de75233c129edb94ff11a75872699dd0dbcd7204256cb8de1354420544cd

See more details on using hashes here.

Provenance

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

Publisher: release-python.yml on mitsuru/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.5.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pyfulgur-0.5.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.9 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.5.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e49856111fba933c714efb80863ffcd2b8e7f3faeb6d87a26daf625a6aee9688
MD5 75aaf213789aa6a6cad9c2a87dc9e9dc
BLAKE2b-256 12595b5dea35f4fe4f7c6873476ec9e7ba80c197602d9e0b9fa1622810ee7345

See more details on using hashes here.

Provenance

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

Publisher: release-python.yml on mitsuru/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.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 56075663a9e77245da11700e941b390f8c17600f463995d3185be2909c182ca9
MD5 cc616f0ddbeb35095c00fb1637168efd
BLAKE2b-256 378d616bb6854dacd54ca27105456a25f17e9dfb73a56d3d1d5e21736479df49

See more details on using hashes here.

Provenance

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

Publisher: release-python.yml on mitsuru/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.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3d1dec14b4f9435a5d79b941ad16716a49dc5728b693923290038fb130d236e6
MD5 c7160aebc054d3eda92e717465140787
BLAKE2b-256 54a1d5ea8034a321282f398e24749b3d51954e9f8df79658f384b788e8f940e6

See more details on using hashes here.

Provenance

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

Publisher: release-python.yml on mitsuru/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.5.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4d6a55ee6df605a3b359863bd118c8889c12bbb6a8513c6c976eb289489a2c7
MD5 6f078dc0584f52f27bc9def04c26e50b
BLAKE2b-256 04f7a0e41b864fa2108e24360dc6af1bbd503c1ddb4a9d0b2274c7ca46459c71

See more details on using hashes here.

Provenance

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

Publisher: release-python.yml on mitsuru/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.5.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyfulgur-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b8ba217d6edbdf30b1cdb27c92ca37b504aa56fb3022d5d25ee22904448ae5bb
MD5 fc5b4f01d2f3736b76708e251042cff6
BLAKE2b-256 42ddbe750d2ed792d6d468921f05396d36a595a49e030a9ebd98ed596c522633

See more details on using hashes here.

Provenance

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

Publisher: release-python.yml on mitsuru/fulgur

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

Supported by

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