Recipe: DocBook PDF Conversion
Recently I had to create a PDF version of a DocBook document. "Easy, I naively thought", and used the already installed docbook2pdf command:
docbook2pdf is one in a suite of conversion programs which you get on Debian via
The problem with the result: It is ugly as hell.
Throwing a Key into its Lock
The font is far too small, the space between paragraphs and other blocks too big, no table of contents, ...
"Easy, I naively thought" assuming that I could control all this via some parameters. And indeed the manual page of jw promises such:
[ -V variable[=value] ]
As the documentation in
is very, very silent about any specific DocBook parameters, I had to scratch them out of
But all my attempts to pass in something which took effect were in vain:
docbook2pdf -V bf.size=11pt ...
docbook2pdf -V %bf-size%=11pt ...
"Not easy, I thought." I cursed the programmer, and gave up on throwing a key into its lock.
After a while I discovered that the whole process is controlled via the DSSSL file:
I cloned a local copy and modified that:
Things I added to the PRINT section (you will find it):
(define %para-sep% (/ %bf-size% 4.0))
(define %block-sep% (* %para-sep% 1.0))
What remained is to name that DSSSL file in the invocation:
Table of Contents
was not enough (I have a DocBook article, not a book). I also had to add a <toc/> empty element to the DocBook. And according to the grammar it must follow all sections.
Strangely, the table of contents appears at the beginning. But in my case that was wanted anyway.
In a weak moment I fell for the theory (never hope for anything!) that the parameters were the same as those for xsltproc, as listed in
They look so strikingly similar. But that is exactly what the devil wanted to fool us. I almost could hear him sneeringly laughing when I tried:
(define %draft-watermark-image% file:draft.png)
And all the useless things these hands have done.
-- Leonard Cohen