This is an alternative implementation of ReportLab's RML PDF generation XML
format. Like the original implementation, it is based on ReportLab's
reportlab
library.
You can read all about z3c.rml
and see many examples on how to use it,
see the RML Reference
Install on pip:
pip install z3c.rml
z3c.rml is then available on the commandline as z3c.rml.:
$ z3c.rml --help usage: rml2pdf [-h] xmlInputName [outputFileName] [outDir] [dtdDir] Converts file in RML format into PDF file. positional arguments: xmlInputName RML file to be processed outputFileName output PDF file name outDir output directory dtdDir directory with XML DTD (not yet supported) optional arguments: -h, --help show this help message and exit Copyright (c) 2007 Zope Foundation and Contributors.
Save this file as file.rml:
<!DOCTYPE document SYSTEM "rml.dtd"> <document filename="example_01.pdf"> <template showBoundary="1"> <!--Debugging is now turned on, frame outlines --> <!--will appear on the page --> <pageTemplate id="main"> <!-- two frames are defined here: --> <frame id="first" x1="100" y1="400" width="150" height="200"/> <frame id="second" x1="300" y1="400" width="150" height="200"/> </pageTemplate> </template> <stylesheet> <!-- still empty...--> </stylesheet> <story> <para> Welcome to RML. </para> </story> </document>
Then run:
$ z3c.rml file.rml
The output will be example_01.pdf as defined in the document
Codewise you can do:
from z3c.rml import rml2pdf rml2pdf.go('file.rml','file.pdf')