Loading repository data…
Loading repository data…
thejchap / repository
A pure-Rust HTML/CSS to PDF renderer with Python bindings. An alternative to WeasyPrint with zero system dependencies.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A pure-Rust HTML/CSS to PDF renderer with Python bindings. An alternative to WeasyPrint with zero system dependencies — no Pango, Cairo, or GObject stack to install.
Docs: thejchap.github.io/pdfun · Parity matrix: docs/PARITY.md · Issues: GitHub
With uv:
uv add pdfun
Or with pip:
pip install pdfun
Python 3.12+. Wheels are published for Linux (x86_64), macOS (arm64), and Windows (x86_64) — no system libraries to install. See Getting Started for uvx / pipx one-shot usage and upgrade commands.
from pdfun import HtmlDocument
doc = HtmlDocument(string="""
<style>
body { font-family: sans-serif; margin: 2cm; }
h1 { color: navy; }
</style>
<h1>Hello, pdfun!</h1>
<p>A pure-Rust HTML/CSS to PDF renderer.</p>
""")
doc.write_pdf("output.pdf")
from pdfun import PdfDocument, Layout, TextRun
doc = PdfDocument()
layout = Layout(doc)
layout.add_text("Hello, world!", font_size=24.0, spacing_after=12.0)
layout.add_paragraph(runs=[
TextRun("Bold text", font_name="Helvetica-Bold"),
TextRun(" and normal text."),
])
layout.finish()
doc.save("output.pdf")
pdfun render input.html -o output.pdf
More runnable examples live in examples/.
border-radius, box-sizing::before / ::afterfont-family (14 built-in PDF fonts), font-weight, font-style, line-height, letter-spacing, text-align, text-decoration#rgb/#rrggbb/#rrggbbaa, rgb()/rgba(), hsl()/hsla()@page, page-break-*, orphans, widows, @media print, @importfloat, clear, overflow, position: relative, display: block | inline | inline-block | list-item | nonebackground-color, background-image: url(...) with repeat / size / positiontoc=True)calc() expressions in lengthsSee CSS Support for the full list including pitfalls, and docs/PARITY.md for the auto-generated per-behavior status.
~114 of 133 tracked CSS behaviors implemented. Non-goals for now: flexbox, grid, @font-face / custom fonts, position: absolute/fixed, SVG, PDF encryption. The parity matrix is the authoritative list and is regenerated by CI from tools/parity/catalog.toml + inline # spec: markers in tests.
See CONTRIBUTING.md for the local dev loop, commit conventions, and the stacked-PR workflow.