Registry / serialization / z3c-rml

z3c-rml

JSON →
library5.1.1pypypi✓ verified 83d ago

An alternative implementation of Report Markup Language (RML) for generating PDFs. Provides a Pythonic API to produce RML XML that can be rendered by ReportLab. Current version 5.0.1, requires Python >=3.9. Maintained by the Zope Foundation with a slow release cadence.

pip install z3c-rml
INSTALL
IMPORT
SIG · Z3C-RML
Z
z3c-rml
serializationpythonv5.1.1
Install
5.4s avg
Import
1814ms
Disk
86MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 6.6s
py 3.11
✓ —
✓ 5.3s
py 3.12
✓ —
✓ 4.8s
py 3.13
✓ —
✓ 5s
py 3.9
✕ build_error
✕ build_error
86MB installed
● package 86MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RML2PDF
from z3c.rml import rml2pdf
from z3c.rml.rml2pdf import RML2PDF
RML2PDF is obtained via the module, not directly imported; use the module-level functions.
story
from z3c.rml import story
import z3c.rml.story
Access story elements via attribute of the module, not submodule import.

Minimal example: create a document, add a paragraph, and render to PDF.

from z3c.rml import rml2pdf, story from io import BytesIO # Create a simple RML document (this is a Pythonic representation, not raw XML) doc = story.DocTemplate( pagesize=(595.27, 841.89), # A4 title="Hello World" ) story = doc.story story.append(story.Paragraph("Hello, World!", style=story.ParagraphStyle(name='Normal'))) # Generate PDF buf = BytesIO() rml2pdf.go(doc, buf) buf.seek(0) print("PDF generated, size:", len(buf.read()))
z3c-rml --version
Debug
Known issues
gotchaz3c.rml uses a Pythonic object model, not raw RML XML. Do not try to pass raw RML strings; use the story objects.
fix
Use `z3c.rml.story` classes (DocTemplate, Paragraph, etc.) instead of manually constructing XML.
affects: all
deprecatedThe old `z3c.rml.rml2pdf` module had different function signatures. In version 5.0, the preferred method is `rml2pdf.go(doc, output)`. The old direct class instantiation may still work but is not recommended.
fix
Use `from z3c.rml import rml2pdf; rml2pdf.go(doc, output)`.
affects: >=5.0
gotchaThe library expects a `BytesIO` or a file path for output. Passing a string path works, but avoid passing a file-like object that is not seekable.
fix
Ensure output is a writable bytes buffer or a string path to a file.
affects: all
Errors
Common errors & fixes
AttributeError: module 'z3c.rml' has no attribute 'story'
Incorrect import. The library is structured so that `z3c.rml` is a namespace package; you must import submodules explicitly.
fix
Use `from z3c.rml import story` instead of `import z3c.rml.story`.
ImportError: cannot import name 'RML2PDF' from 'z3c.rml'
Trying to import the old class directly from the package root. In modern versions, use `from z3c.rml import rml2pdf`.
fix
Replace `from z3c.rml import RML2PDF` with `from z3c.rml import rml2pdf`.
TypeError: go() takes at least 2 positional arguments (0 given)
Calling `rml2pdf.go()` without arguments or with incorrect arguments. The function expects a doc and an output.
fix
Correct usage: `rml2pdf.go(doc, output)` where doc is a story.DocTemplate and output is a file path or BytesIO.
Upgrade
Version history
5.1.1latest on PyPI · released May 21, 2026
Audit
Dependencies
reportlabrequiredRequired for PDF generation from RML
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
z3c-rml — pip install z3c-rml · libregistry