3.3. Example 2: convert a DocBook document to PDF
Prev | 3. The convertdoc command-line tool | Next

### 3.3. Example 2: convert a DocBook document to PDF

Convert DocBook document `doc.xml` to `commands.pdf` (the `docb.toPSFile` process command is found in ``XXE_install_dir`/addon/config/docbook/xslMenu.incl`).

    $ convertdoc -t fo_docbook.xsl \
        -p toc.section.depth 4 -p callout.graphics 0 -p variablelist.as.blocks 1 \
        docb.toPSFile doc.xml \
        -s pdf -s "|pdf" -u docs/commands/commands.pdf

Note that an alternate XSLT style sheet, `fo_docbook.xsl`, is used instead of the stock `docbook.xsl` which is part of Norman Walsh's DocBook XSL stylesheets.

Figure 5.2. `docb.toPSFile` and excerpts of `docb.toPS`

      <command name="docb.toPS">
        <process>
         .
         .
         .
            <resources match="(?:.+/)?(.+)\.(png|jpg|jpeg|gif|svg|svgz%1)"
                       copyTo="resources" referenceAs="resources/$1.$2" />
         .
         .
         .
            <processFO processor="FOP" file="__doc.fo" to="__doc.%0">
              <parameter name="renderer">%0</parameter>
              <parameterGroup name="docb.toPS.FOPParameters" />
            </processFO>
         .
         .
         .
      </command>

      <command name="docb.toPSFile">
        <process>
          <subProcess name="docb.toPS" parameter='"%0" "%1"' />

          <upload base="%2">
            <copyFile file="__doc.%0" to="%2" />
          </upload>
        </process>
      </command>

The `docb.toPSFile` process command expects 3 arguments:

%0

  Specifies the output format: `pdf` or `ps`. This argument is passed to the process command using "`-s pdf`".

%1

  Specifies the image formats other than GIF, JPEG and PNG natively supported by the XSL-FO processor for the chosen output format: "`|pdf`" or "`|eps|ps`". This argument is passed to the process command using "`-s "|pdf"`".

%2

  Specifies the output file URL. This argument is passed to the process command using "`-u docs/commands/commands.pdf`".

Prev | Up | Next
3.2. Example 1: convert a DocBook document to multi-page HTML | Home | Chapter 6. Commands written in the Java™ programming language