Docbook publishing as PDF with bookmarks on Windows

Just a note to remember that Docbook publishing on Windows isn’t as easy as on Linux, but still not that hard :

  1. Download FOP and Saxon
  2. Create a stylesheet fop.xsl :
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:import
    href="http://docbook.sf.net/release/xsl/current/fo/docbook.xsl"/>
    <xsl:param name="paper.type" select="'A4'"/>
    <xsl:param name="fop.extensions" select="0"/>
    <xsl:param name="fop1.extensions" select="1"/>
    </xsl:stylesheet>
  3. Create a batch :
    saxon.jar -o GuideFoo.fo GuideFoo.xml E:\dev\dbk\fop.xsl
    fop.bat -fo GuideFoo.fo -pdf GuideFoo.pdf

Notes :

  • The fop extension defined in the XSL will allow bookmarks creation
  • If you have images you may have to install JIMI, JAI for FOP too.
  • It supposes that you have an good Internet connection and no proxy. Otherwise, you can download the Docbook XSL and for proxy, add “java -DproxySet=true -DproxyHost=proxy.provider.com -DproxyPort=3128 -jar”
  • Some uses Ant to publish Docbook, it is very efficient. Makefile is also an option, there are examples in Docbook XSL distribution.
  • Saxon isn’t the only choice, xsltproc may be faster, specially if you don’t use Saxon’s extensions.

One Response to Docbook publishing as PDF with bookmarks on Windows

  1. It could also be done using the Maven Docbkx Plugin, if you are used to Maven. Using the Maven Docbkx Plugin, you would simply have to add this to the plugins section of your pom.xml file:

    com.agilejava.docbkx
    docbkx-maven-plugin
    1.69.1.3-SNAPSHOT

    org.docbook
    docbook-xml
    4.4
    runtime

    The latest version (that hasn’t been released yet though) also generates PDF, using FOP 0.20.5. Parameters are not specified by adding your own XSLT customization layer, but instead by using plugin configuration parameters. (See http://www.agilejava.com/docbkx/docbkx-maven-plugin/generate-fo-mojo.html for an overview of all paremeters. Note the one-to-one correspondence with the XSLT params.)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: