PDFNode
PDFNode is Zope tool to help creating aggregated PDF files from HTML, LaTeX, PDF and other sources.
Current release
PDFNode 0.3.0
Released Sep 02, 2008 — tested with Plone 2.5, Plone 3
Initial release, in beta stage but working and used on production.
More about this release…
Get
PDFNode
for
all platforms
(0 kB)
- Product Package
Project Description
See COPYING and AUTHORS for copyright information.
Usage
PDFNode is a Zope (or Python) product to generate PDF files from different inputs: HTML, PDF or LaTeX. It doesn't handle PDF generation itself (htmldoc or pdflatex do it), but it handles the multiplexing of those formats into on final file.
The typical use is to create a PDFDocument object, to configure it, to add data (which can be divided into sections) to it, and then to generate the final document.
Prerequisite
PDFNode requires:
- Zope 2.7 or higher (Python 2.3 or higher)
- pdflatex
- htmldoc for the text/html support
The PDFDocument class can also be used outside of Zope, with Python 2.3 or higher.
If BlueDCS is installed, PDFNode will be able to use it to convert Office documents to PDF.
API overview
The main tool (PDFNode) provides three methods:
- newPDF
This create a new, preconfigured, PDFDocument object.
This object can be then filled with content.
- generate
- Generate a PDF file from a PDFDocument object and the name of the file. It'll set HTTP headers so the download will be started as desired.
- renderAsPdf
- This is a helper method calling the two previous ones to convert a HTML string (with optional PDF attachments) into a PDF file.
The PDFDocument class provides several methods:
- configure/reconfigure
- Those two methods can be used to dynamically change properties, like TOC generation, name of commands to use, ...
- set_title
- Sets the global document title (and author name).
- add_data
This the main method, adding data to the PDF file. The data and mimetype must be provided, and additional informations like section and title (for TOC generation) can be provided.
Out of the box, PDF, LaTeX, HTML and plain text are supported.
- add_*
- Those methods are helper to the previous one.
- add_list, add_description
- Add a bullet list, or a key/value list, using LaTeX code.
Extending
PDFNode can be easily extended to support additionall renders. You can have a look in the PDFRenderers/ directory for more informations. Registering a new render, for now, has to be done by doing
from Products.PDFNode.PDFRenderers import renderers renderers[my_mimetype] = MyRenderClass
Future versions
Usage of pisa instead of htmldoc to convert HTML to PDF is planned in a future version.
