Example: Creating a simple PDF plug-in Simple PDF plug-in example This scenario walks through the process of creating a very simple plug-in (com.example.print-pdf) that creates a new transformation type: . figure PDFplug-in integrator.xml catalogexample

The transformation has the following characteristics:

  • Uses A4 paper
  • Renders figures with a title at the top and a description at the bottom
  • Use em dashes as the symbols for unordered lists
In the plugins directory, create a directory named com.example.print-pdf. In the new com.example.print-pdf directory, create a plug-in configuration file (plugin.xml) that declares the new transformation and its dependencies. <filepath>plugin.xml</filepath> file Add an Ant script (integrator.xml) to define the transformation type. <filepath>integrator.xml</filepath> file In the new plug-in directory, add a cfg/catalog.xml file that specifies the custom XSLT style sheets. <filepath>cfg/catalog.xml</filepath> file Create the cfg/fo/attrs/custom.xsl file, and add attribute and variable overrides to it. For example, add the following variables to change the page size to A4. <filepath>cfg/fo/attrs/custom.xsl</filepath> file Create the cfg/fo/xsl/custom.xsl file, and add XSLT overrides to it. For example, the following code changes the rendering of figure elements. <filepath>cfg/fo/xsl/custom.xsl</filepath> file Create an English-language variable-definition file (cfg/common/vars/en.xml) and make any necessary modifications to it. 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. <filepath>cfg/common/vars/en.xml</filepath> file 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
  1. Run --install to install the plug-in and make the transformation available.
  2. Build output with the new transformation type to verify that the plug-in works as intended. --input=my.ditamap --format=