1.7. Translation to PDF

Instead of generating an HTML hyper-document it is somethimes necessary to produce a nicely printable copy. Therefore, starting from the same DocBook XML source document and using an alternative XSLT style sheet one can generate XSL-FO formatting objects, that can the be translated into various media formats, in particular PDF with oneof several XSL-FO to PDF translators.

At CERN a script, docbook2pdf, hides the details of this translation process from the user. By default the script takes one argument, the name of the XML source to be transformed into PDF, for example,

Example 1.6. Generating PDF with docbook2pdf

$ docbookpdf dbfile.xml
docbook2pdf dbfile.xml
dbfile.xml abc.xsl dbfile.fo
 
 Using java 1.4 from AFS.
 
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

Making portrait pages on A4 paper (210mmx297mm)
 
 running pdftex/passivetex (twice): pdfxmltex dbfile.fo
 
This is pdfTeX, Version 3.14159-pre-1.0-unofficial-20010704 (Web2C 7.3.3.1)
(./dbfile.fo{/afs/cern.ch/sw/TeXlive/tl7/texmf-var/pdftex/config/pdftex.cfg}
LaTeX2e <2001/06/01>
...
Output written on dbfile.pdf (1 page, 7710 bytes).
Transcript written on dbfile.log.

This is pdfTeX, Version 3.14159-pre-1.0-unofficial-20010704 (Web2C 7.3.3.1)
(./dbfile.fo{/afs/cern.ch/sw/TeXlive/tl7/texmf-var/pdftex/config/pdftex.cfg}
...
Output written on dbfile.pdf (1 page, 7710 bytes).
Transcript written on dbfile.log.

In the above we see that first a XSLT translator (saxon) is run that generates XSL-FO elements, that are then rendered into PDF by pdftex, a variant of the TeX program that generates PDF. Thus we obtain a file dbfile.pdf, which can be seen in Figure 1.1.

Figure 1.1. PDF rendering of a small DocBook test file

PDF rendered image of
             dbfile.xml

The file dbfile.pdf can be viewed with ghostview or acroread, and can be sent by these applications to a PostSCript printer.

What we obtained with the previous example is the default presentation as defined by the style sheets of Norman Walsh. In fact, Norman parameterized his style sheets in a convenient way, so that over one hundred parameters are available to finetune the format of the output page. At CERN you can specify a second filename to the docbook2pdf command, and when specified, it will be used as an XSLT customization style sheet, for instance, at CERN you could type:

$ docbookpdf dbfile.xml dbforpassivetex.xsl

If you are interested in such customization, you can start from the style sheet dbforpassivetex.xsl that is available from the docbook DocBook Web page at CERN. A full discussion of all parameters can be found in the [reference guide] entry in the [DocBook XSLT stylesheets] section of the above Web page.