Long-term archiving · Python
Create PDF/A in Python
pip install rustpdf and generate archival PDF/A-1b through A-4 from a FastAPI or Celery job, with fonts auto-embedded, sRGB ICC and XMP added, output validated by veraPDF. rust-pdf embeds the sRGB ICC profile, adds the output intent, writes the XMP metadata and document ID, and enforces the rules, so the output validates under veraPDF, the reference validator.
Last updated: 2026-06-29
Why Python needs this
PDF/A seals everything a renderer needs inside the file (fonts, the sRGB ICC profile, an output intent and XMP metadata) so a document opens identically decades from now. rust-pdf exposes each conformance level explicitly: PdfaLevel.A2B for visual fidelity, an a-level for an accessible tagged tree, or a 3/4f-level when you must embed source files such as a ZUGFeRD or Factur-X invoice XML.
The one rule that trips up Python developers is fonts: PDF/A forbids the standard-14 shortcut, so every glyph must come from an embedded program. With rust-pdf you call add_font_file with a TTF/OTF once and the subset, the /CIDSet and the metadata are written automatically. There is no separate font-registration step or external Ghostscript pass to maintain.
Generation is pure in-process work, so a FastAPI endpoint or a Celery worker can build a report and return the doc.save(...) bytes with no system PDF toolchain in the image. To prove conformance in CI, run the output through veraPDF (-f 2b or -f 2a); qpdf and mutool cover the structural layer.
- Levels A-1b, A-2b, A-2a, A-3b, A-3a and A-4 (the PDF 2.0 part), with the accessible a-levels building a full tagged structure tree.
- Fonts embedded and subset automatically, ICC profile and output intent added for you.
- XMP metadata kept in sync with the document info, validated by veraPDF.
Create PDF/A in Python with rust-pdf
Install with pip, then call the same idiomatic API every rust-pdf binding shares. The snippet below is real Python code from the reference docs.
pip install rustpdf
from rustpdf import Document, PdfaLevel
with Document() as doc:
doc.pdfa(PdfaLevel.A2B).set_info(title="Q3 Report", author="Acme Inc.")
f = doc.add_font_file("Roboto-Regular.ttf")
doc.add_page()
doc.show_text(f, 20, 72, 760, "Archival report")
doc.save("report_pdfa.pdf") # raises PdfError without a license granting PDF/A
Python basic generation is free. PDF/A is a corporate feature, unlocked by one offline license token. See pricing & licensing.
Full Python reference in the documentation.
PDF/A in Python: FAQ
Which PDF/A levels are supported in Python?
rust-pdf creates PDF/A-1b, 2b, 2a, 3b, 3a and 4 (the PDF 2.0-based part, including 4e and 4f). Use a basic b-level for visual fidelity, an a-level for an accessible tagged structure, or a 3-level when you need to embed source files such as an e-invoice XML.
How is conformance verified?
Output is validated with veraPDF, the open-source reference validator for PDF/A, plus qpdf and mutool for structure. The claim is backed by validators, not adjectives.
Do I need a license to create PDF/A in Python?
PDF/A is a corporate feature and requires an active license token. Basic generation in Python is free. One offline token unlocks PDF/A in every supported language.
Does the pip wheel work on Alpine Linux?
Yes, but pick the right wheel. The default manylinux wheels are built against glibc; Alpine and other musl-based images need the musl wheel of rustpdf so the bundled native library links correctly. Once the matching wheel is installed, generating PDF/A in a small Alpine container needs no Ghostscript, veraPDF or other system package at runtime.
Start creating PDF/A in Python
One Rust core, the same output across every language. Prototype for free, license the corporate features when you ship.