DocBook to PDF 2


Well, after my previous post I looked a bit further into what’s available on feisty and discovered the dblatex package. It’s kind of a rewrite of db2latex, that’s actively maintained and already comes with its own executable.

So forget my previous post and the quick hack I presented there and just use dblatex, i.e. dblatex -bpdftex. Both calls will produce PDF output directly, but the second one goes directly from LaTeX to PDF, without intermediate steps of DVI and PS.


I just looked into ESR’s DocBook Demystification HOWTO. After reading that, I wanted to try to produce PDF output from DocBook XML on my own Linux box which is running Ubuntu.

But neither of the necessary packages for this task which are mentioned in the HOWTO is in Ubuntu feisty. xmlto is there, but needs passivetex, which was in earlier Ubuntu releases, but was removed (It was removed from Debian, too.). fop is also not in Ubuntu, though it is in Debian.

But I found another package in Ubuntu: db2latex-xsl, which contains XSL stylesheets to turn DocBook XML into LaTeX with the help of a XSL processor like xsltproc. The LaTeX file can then be processed with pdflatex to produce PDF.

Here is the shell script I wrote for this:

$ cat ~/bin/db2latex


for i
    basename=`basename "$i" .xml`
    xsltproc -nonet -o "$basename.tex" \\
    /usr/share/xml/docbook/stylesheet/db2latex/latex/docbook.xsl "$i"

Call this with db2latex foo.xml and then pdflatex foo.tex to get a PDF file foo.pdf from a source file foo.xml.