You are here:   » Home » Documentation » Details » How-To » Print » PDF-Druck

PDF-Druck mit XSL

Author: Dr. Frank Hoffmann, 2005/09/05

Since ZMS 2.1 a new configuration interface for free definable transformators ('filters') is available; a filter consists of a string of single steps ("processes') which take over the control of the external converter application.

The following example shows the ZMS filter concept by means of a filter for the export of a ZMS publication as OpenOffice-document.
Since ZMS 2.1 a menu entry "filter" exists in the ZMS configuration. Here two element types can be configured:

  1. Filter is a sequence of processes together with specific XSL/conf-files and
  2. Processes allow the computer-specific parametrisation of the transformer/converter in form of a configuration of the needed single-step-calls of the external applications.
Zoom (86KB)

Filter menu: definition of filters and processes

To write e.g. an OpenOffice-filter you proceed as follows:

  1. Creation of target elements in OO and related fine definition of layout
  2. Extraction of OO-preamble (XML-code in the kind of <office:font-decls><style:font-decl style:name="StarSymbol" fo:font-family="StarSymbol" style:font-charset="x-symbol"></style:font-decl>...) as "processing instruction" for the introduction of the transformation result and the Styles.xml; both files as well as if needed additional required fragments (for addments etc.) are implanted into the content at defined nodes (see screenshot below) and through the later transformation process re-written into the target stream.
  3. Configuration of corresponding format elements in ZMS
  4. Programming of the XSL transformer
  5. Configuration of a ZMS filter that sequences the XSLs (normally there are the two transformation steps 1. XHTML 2. OOXML.)
Zoom (29KB)

A filter consists of a sequence of 'processes'; to each 'process' a configuration file resp. transformation file (e.g. XSL-file) is handed over.

Zoom (23KB)

Exemplary content flow with interspersed "processing instruction" elements which prepare special section in the target format already in ZMS (e.g. layout variation in the addment, position of table of contents etc.)

For an experienced export it is recommended to regard further details:
if the exported OO-document is finally set fine after the export and the make-up is polished by the image sizes, the invested work should not be in vain with the follow-up export (of a new edition). For this an XSL method can be developed, with which the export can extract the OO-specific image parameter from the last OO-typesetting, meaning: the export "learns from the old edition".

A reverse transformation is to be implemented in an analogical way. Of course, precondition is in both cases the strict correspondence of all format elements. In case of such transformations the DTD conformity pays off: it is clear that non-defined (in-line) elements resp. non-XHTML artifacts more or less can constrain the transformation.

PDF generation with HTMLdoc

The command line tool 'HTMLDOC' allows a relative simple but in most cases sufficient conversion of HTML streams to PDF format. The related filter needs two steps only:

  • HTML normalisation with Tidy ("cleansing" of the HTML code)
  • Transfer of the HTML stream to HTMLdoc for transformation to PDF

Tidy configuration: the UTF-8-Codes from ZMS must be changed to Latin-1 to be correctly transformed by HTMLdoc.

add-xml-decl: no
doctype: omit
enclose-block-text: yes
enclose-text: yes
input-encoding: utf8
char-encoding: utf8
output-encoding: latin1
drop-font-tags: yes
numeric-entities: yes

Installation: HTMLdoc and Tidy must be installed on the system resp. their paths must be known. The XML configuration file below is imported into the configuration menu "filter". The programme paths are adapted in both batch steps "htmldoc" and "tidy".

Zoom (109KB)

HTMLdoc filter for generating PDF

IMPORTANT NOTE: The paths for the programme calls (e.g. C:\Programme\HTMLDOC\) used in both batch steps must be adapted to the local situation so that the programme call of the ZMS filter will work.
With Linux both process steps might look e.g:

htmldoc --book --toctitle "Table of Contents" --header t.l
--size A4 -t pdf13 -f {out.pdf} {in}

tidy -asxml -config {trans} -m {in}

Resources

text/xml   HTMLdocFilter.xml (2KB)
Configuration file for the HTMLdoc filter
Print this Document   change language   Sitemap   Contact