Overview¶
Docma was developed at Origin Energy as part of the Jindabyne initiative. While not part of our core IP, it proved valuable internally, and we're sharing it in the hope it's useful to others.
Kudos to Origin for fostering a culture that empowers its people to build complex technology solutions in-house.
Docma is a PDF document generator that can assemble and compose PDF and self-contained HTML documents from document templates with dynamic content.
Features include:
- PDF document generation with source content defined in any combination of HTML and PDF.
- HTML document generation from source content in HTML.
- Compilation of Markdown source content into HTML
- Dynamic content preparation (conditionals, loops, transformation etc.) based on structured data parameters fed to the rendering process at run-time.
- Dynamic content injection from multiple data sources, including live database connections.
- Composition of multiple source documents into a single PDF or HTML output.
- Conditional inclusion of component documents based on parameter based conditions evaluated at run-time.
- Deep schema validation of structured data parameters at run-time.
- Watermarking / stamping of PDF output.
- Dynamic generation of charts via the Vega-Lite specification with multiple data sources, including live database connections.
- Extensible interfaces for content assembly, dynamic content generation and data access.
- Locale support for content such as numbers, currencies, phone numbers etc.
Creating Documents with Docma¶
The docma document creation process consists of these steps:
-
Document template creation: The template content is contained in a directory dedicated to a single template. It contains the static content (e.g. HTML, PDF, Markdown and image files) as well as YAML formatted metadata files that control the rendering process, database access etc.
-
Template compilation: The compilation process validates the template content, converts supported non-HTML content (e.g. Markdown files) into HTML and generates a compiled template package in either a directory or ZIP file.
-
Template rendering: The rendering process uses Jinja to inject run-time parameters into the HTML template content, converts the component documents to PDF, if required, and composes all of the components into a single output PDF or standalone HTML document.