ftw.pdfgenerator 1.2.8

Introduction

ftw.pdfgenerator is meant to be used for generating PDFs from structured
data using predefined LaTeX views. It is not useful for converting
full HTML pages into LaTeX / PDFs, although it is able to convert small HTML
chunks into LaTeX.

Certified: 01/2013

Requirements

ftw.pdfgenerator requires a TeX distribution with a pdflatex executable to be installed.

There are more methods on the layout, see the definition in
ftw.pdfgenerator.interfaces.ILaTeXLayout.

Defining a LaTeX view

For every context for which a PDF is generated a LaTeX view (ILaTeXView)
is rendered. The view is a multi adapter adapting context, request, layout.
There is a view based on the mako templating engine which can be extended
(example: views.py):

Generating a PDF

When a layout and a view for the context are registered the PDF can be
generated by simply calling the view @@export_pdf on the context.

Recursive views

When extending from ftw.pdfgenerator.view.RecursiveLaTeXView and inserting
the variable latex_content in your template, the view automatically renders
all children for which a ILaTeXView is found.

HTML to LaTeX conversion

ftw.pdfgenerator comes with a simple but powerful HTML to LaTeX converter
which is optimized for the common WYSIWYG-Editors used in Plone.

The converter can be used:

in views, using self.convert(html)

in layouts, using self.get_converter().convert(html)

It uses regular expressions for the simple conversions and python
subconverters for the more complicated conversions. The converter is heavily
customizable.

Customizable layouts

When using multiple, independent addon packages using ftw.pdfgenerator,
every package may implement a new, specific layout. This can be painful if
there is a need to customize all layouts and add a logo image for example.

For making this easier all customizable layouts can be customized with one
single adapter. This only works for layouts subclassing
ftw.pdfgenerator.layout.customizable.CustomizableLayout. Those layouts
need to follow certain concepts and provide inheritable blocks in the mako
template. Ensure you follow the standards by subclassing and running the
tests from
ftw.pdfgenerator.tests.test_customizable_layout.TestCustomizableLayout.

Implementing customization adapter is very simple when customizable layouts
are used. For example we change the logo image (assume the logo is at
custom/mylogo.png):