3.2. Example 2: Convert a DocBook document to PDF
Prev | 3. The convertdoc command line tool | Next

### 3.2. 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" -s "/book toc" -s 1 -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="%w/resources/$1.$2" />
         .
         .
         .
            <parameter name="generate.toc">%2</parameter>
            <parameter name="toc.section.depth">3</parameter>
            <parameter name="section.autolabel">%3</parameter>
         .
         .
         .
            <processFO processor="FOP" file="__doc.fo" to="__doc.%0">
              <parameter name="renderer">%0</parameter>
              <parameterGroup name="docb.toPS.FOPParameters" />
            </processFO>
         .
         .
         .
          <upload base="%4">
            <copyFile file="__doc.%0" to="%4" />
          </upload>
        </process>
      </command>

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

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

The `docb.toPSFile` process command expects 5 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 value of XSLT style sheet parameter "`generate.toc`" (see DocBook XSL Stylesheet Documentation). This argument is passed to the process command using "`-s "/book toc"`".

%3

  Specifies the value of XSLT style sheet parameter "`section.autolabel`" (see DocBook XSL Stylesheet Documentation). This argument is passed to the process command using "`-s 1`".

%4

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

Prev | Up | Next
3.1. Convert a DocBook document to multi-page HTML | Home | 3.3. Example 3: Convert a DocBook document to JavaHelp™