Skip to main content

formepdf

Python SDK for Forme — a page-native PDF rendering engine. Build documents from a component DSL and render them to PDF locally, in-process, with no browser, no headless Chromium, and no system libraries — the engine ships as a single WebAssembly module and runs anywhere Python runs (including serverless).

  • Local rendering via wasmtime — no API key, no network calls.
  • Real print features — flexbox layout, tables with headers that repeat across pages, fixed headers/footers, page breaks, watermarks.
  • Accessible & archival — tagged PDF, PDF/UA-1, and PDF/A produced locally, the same conformance the engine gives everywhere.
  • Charts, QR codes, barcodes, and fillable form fields built in.
  • Local digital signing (PKCS#7 / X.509).

Installation

pip install formepdf[local]

The [local] extra adds wasmtime; the engine WASM is bundled in the wheel. That's all you need — no cairo, no pango, no fonts to install.

Quick start

from formepdf import Document, Page, View, Text

doc = Document(
    Page(
        View(
            Text("Invoice #001", font_size=24, font_weight="bold"),
            Text("Acme Corp", font_size=14, color="#666"),
            flex_direction="column", gap=8,
        ),
    ),
    title="Invoice #001",
)

pdf = doc.render()               # -> bytes

with open("invoice.pdf", "wb") as f:
    f.write(pdf)

Accessible & archival output

The conformance options live on Document — no extra pipeline, no external validator step to produce them:

doc = Document(
    Page(Text("Annual Report 2026", font_size=20)),
    title="Annual Report 2026",
    lang="en",
    tagged=True,     # structure tree (BDC/EMC marked content)
    pdf_ua=True,     # PDF/UA-1 (accessibility)
    pdfa="2b",       # PDF/A-2b (archival); also "2u", "2a", "3b", "3u", "3a"
)
pdf = doc.render()

Document options: title, author, subject, lang, tagged, pdf_ua, pdfa, embed_standard_fonts, flatten_forms. embed_standard_fonts=True embeds Helvetica, Times and Courier as their metric-compatible substitutes (register the fonts-standard TTFs via fonts) with no PDF/UA or PDF/A claim; render_html takes the same option.

Components

Component Description
Document(*children) Root container. .render() returns PDF bytes. Options: title, author, subject, lang, tagged, pdf_ua, pdfa, flatten_forms
Page(*children) Page container. Options: size (e.g. "A4", "Letter"), margin
View(*children) Flex/grid container. Options: all style kwargs (flex_direction, gap, padding, etc.)
Text(content) Text element. Options: font_size, font_weight, color, text_align, etc.
Image(src) Image (file path, URL, or data URI). Options: width, height, alt
Table(*rows) Table with auto-repeating headers. Options: columns
Row(*cells) Table row. Options: header=True for repeat-on-page-break
Cell(*children) Table cell. Options: col_span, row_span
Svg(content) Inline SVG. Options: width, height
QrCode(data) Vector QR code. Options: size, color
Barcode(data) 1D barcode. Options: format ("Code128", "Code39", "EAN13", etc.), width, height
BarChart(data) Bar chart. Options: width, height, color, title
LineChart(series, labels) Line chart. Options: width, height, show_points, title
PieChart(data) Pie/donut chart. Options: width, height, donut, title
AreaChart(series, labels) Area chart. Options: width, height, title
DotPlot(groups) Scatter plot. Options: width, height, title
TextField(name) Fillable text field. Options: value, placeholder, multiline
Checkbox(name) Fillable checkbox. Options: checked
Dropdown(name, options) Fillable dropdown. Options: value
RadioButton(name, value) Radio button. Options: checked
Watermark(text) Rotated watermark. Options: font_size, color, angle
PageBreak() Force a page break
Fixed(*children) Fixed-position element. Options: position ("header", "footer")

Local digital signing

Apply a PKCS#7 / X.509 signature to an existing PDF, offline:

import json
from formepdf.wasm import certify_pdf

with open("document.pdf", "rb") as f:
    pdf = f.read()

config = json.dumps({
    "certificate_pem": open("cert.pem").read(),
    "private_key_pem": open("key.pem").read(),
    "reason": "Approved",
})

certified = certify_pdf(pdf, config)

HTTP client (optional)

The package also ships a thin HTTP client, Forme. It targets the Forme hosted API at https://api.formepdf.com by default (see https://docs.formepdf.com/hosted-api); point base_url at your own deployment to use a self-hosted Forme server instead. It exposes server-side operations the local WASM engine doesn't: render stored templates by slug (render / render_async / get_job), true redaction (redact), merge, rasterize, and extract.

from formepdf import Forme

client = Forme("forme_sk_...", base_url="https://pdf.your-company.com")
pdf = client.render("invoice", {"customer": "Acme", "total": 245})

Requirements

  • Python 3.8+
  • wasmtime for local rendering (pip install formepdf[local])
  • No system libraries, no browser.

Metadata

Release files for formepdf 0.33.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for formepdf 0.33.0
File Size Uploaded Provenance Actions
formepdf-0.33.0.tar.gz 3.2 MB Without provenance Details for formepdf-0.33.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for formepdf 0.33.0
File Interpreter ABI Platform Actions
formepdf-0.33.0-py3-none-any.whl Python 3 none any Details for formepdf-0.33.0-py3-none-any.whl

Total release size: 6.4 MB

Release files / formepdf-0.33.0.tar.gz

Download URL formepdf-0.33.0.tar.gz
Size 3.2 MB
Tags Source
SHA-256 checksum
How to use checksums
f36f0f8a70d8354ea6baac726465b30641838ea845de9afd2ee23724cb9a4ed8
BLAKE2b-256 checksum
How to use checksums
88e457de071ba79cb4a5d312b1e4091ca483215980e60ac97558b4e235706c53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.12

Release files / formepdf-0.33.0-py3-none-any.whl

Download URL formepdf-0.33.0-py3-none-any.whl
Size 3.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
52f386e4c50252585b63de087150385cb9bbd1f076a24e475076725f07f00ca6
BLAKE2b-256 checksum
How to use checksums
81abb388ff90d7d2e6328f977a3496b5d58e87e8c0d12d3a9cf64ed9e3eb19cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.12

Security for formepdf 0.33.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.33.0 This release

2 release files No provenance

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