Example: Creating a simple PDF plug-in

This scenario walks through the process of creating a very simple plug-in ( com.example.print-pdf ) that creates a new transformation type: print-pdf .

About this task

The print-pdf transformation has the following characteristics:

Procedure

  1. In the plugins directory, create a directory named com.example.print-pdf .
  2. In the new com.example.print-pdf directory, create a plug-in configuration file ( plugin.xml ) that declares the new print-pdf transformation and its dependencies.
Figure 1. plugin.xml file Figure 2. integrator.xml file Figure 3. cfg/catalog.xml file

For example, add the following variables to change the page size to A4. Figure 4. cfg/fo/attrs/custom.xsl file

   210mm 297mm 

For example, the following code changes the rendering of

elements. Figure 5. cfg/fo/xsl/custom.xsl file

For example, the following code removes the period after the number for an ordered-list item; it also specifies that the bullet for an unordered list item should be an em dash. Figure 6. cfg/common/vars/en.xml file

Results

The files for this sample plug-in are included in the DITA-OT installation directory under docsrc/samples/plugins/com.example.print-pdf/ and on GitHub.

The plug-in directory has the following layout and files:

com.example.print-pdf ├── cfg │ ├── catalog.xml │ ├── common │ │ └── vars │ │ └── en.xml │ └── fo │ ├── attrs │ │ └── custom.xsl │ └── xsl │ └── custom.xsl ├── integrator.xml └── plugin.xml

What to do next

  1. Use the dita install subcommand to install the plug-in.
For more information, see Installing plug-ins.
dita --input=my.ditamap --format=print-pdf

Page content generated from DITA source · Last changed in dita-ot/docs@d001d52

DITA Open Toolkit
Code
Community
Events