The Adobe PDF (Portable
Document Format) standard is a ubiquitous
documentation format. The purpose of the
module is to allow Python programs to generate PDF files
There are many routes to PDF, but the author has some experience with the XSL-FO standard, the eXtensible Stylesheet Language Formatting Objects.
Before you read any further, you should be familiar with these technologies.
XML, the ubiquitous eXtended Markup Language.
The document Python XML processing with
lxml is a complete, easy-to-use XML
toolbase for Python. In particular, the
etbuilder module defined in this document
makes the code to generate any XML structure
straightforward and terse.
XSL Formatting Objects (XSL-FO). The term “XSL” is somewhat ambiguous because what was originally one project has fissioned into two.
XSL-FO is a way of describing specific documents. We use it here as a convenient route to PDF format.
The other XSL project, XSLT (eXtended Stylesheet Language, Transforms) is an elegant, pure functional programming language for transforming XML documents into other forms. The vast majority of current practitioners of XSL-FO use XSLT to generate it, but it is outside the scope of this document.
The current document is intended to provide an alternative route to PDF that does not use XSLT, because XSLT operates only on XML input files. We want to provide a route for situations where the content comes from databases or other sources, to which XSLT has no direct interface.
For a readable, well-organized, approachable book on XSL-FO, the author recommends this one.
The translation of an XSL-FO document into the final PDF can be accomplished with several packages; refer to the Wikipedia page for XSL-FO for links. The NM Tech Computer Center has the XEP package from RenderX installed under an academic license; this package produces high-quality output.