Install xsltproc and FOP to generate a PDF from a docbook document

By xngo on February 24, 2019

Install xsltproc

  1. Go here to download iconv, zlib, libxml2 and libxslt.
  2. Decompress all the files downloaded.
  3. Put the folder path of iconv.exe, libxml2.dll, xsltproc.exe and zlib1.dll in the environment variable PATH.
  4. Open Command Prompt and run xsltproc.exe. It should show something similar to the following:
    C:\>xsltproc -version
    Using libxml 20630, libxslt 10122 and libexslt 813
    xsltproc was compiled against libxml 20630, libxslt 10122 and libexslt 813
    libxslt 10122 was compiled against libxml 20630
    libexslt 813 was compiled against libxml 20630  
     

Install Apache FOP

  1. Go here to download fop (e.g. fop-0.95-bin.zip).
  2. Decompress fop (e.g. fop-0.95-bin.zip).
  3. Put the folder path of fop.bat in environment variable PATH.
  4. Open Command Prompt and run fop.bat. It should show something similar to the following:
    C:\gpl\docbook\fop-0.95>fop -v
    FOP Version 0.95
    ...
     

Generate your first PDF docbook

  1. Go here to download the latest version of docbook-xsl (e.g. docbook-xsl-1.75.2.zip).
  2. Decompress docbook-xsl downloaded.
  3. Download MyFirstDocbook.xml, a sample docbook file.
  4. Open Command Prompt and run the following commands(Note:Change the paths accordingly):
    C:\>xsltproc X:\path_to_docbook-xsl_folder\fo\docbook.xsl X:\path_to\MyFirstDocbook.xml > MyFirstDocbook.fo
    C:\>fop MyFirstDocbook.fo MyFirstDocbook.pdf
     

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.