Sunday, January 24, 2010

Generating PDF from docbook on Linux (OSS)

My goal was to generate a PDF file from an input docbook file. Sound easy ? Well here are the minimal steps on a lenny/stable system:

$ sudo apt-get install docbook-xsl


$ sudo apt-get install -t testing fop libjeuclid-fop-java

You absolutely need fop from testing.

Then to get hyphen working you need to follow instructions from:

I used the root solution:

$ cat /etc/fop.conf


$ cat ~/.foprc
find_jars jeuclid-core jeuclid-fop

You really need fop from testing otherwise find_jars will not work !

Then I tried on a very simple MathML/docbook example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.5//EN"
<!ENTITY % MATHML.prefix "mml">
<!ENTITY % equation.content "(alt?, (graphic+|mediaobject+|mml:math))">
<!ENTITY % inlineequation.content
               "(alt?, (inlinegraphic+|inlinemediaobject+|mml:math))">
<!ENTITY % mathml PUBLIC "-//W3C//DTD MathML 2.0//EN"
 <sect1 id="section_Description">
<title>My MathML example</title>
<mml:math xmlns:mml="">

Then execute this way:

$ fop -xsl /usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl -xml math.xml -pdf math.pdf

Here is what it looks like:


No comments: