You already know that you can create the skeleton of DITA open toolkit’s custom pdf plugin using Jarno Elovirta’s PDF Plugin generator. Structure of your pdf plugin must look like the figure below that showsthe structure of my plugin- com.mycompany.website-ug.
Basically what we need to do is override the org.dita.pdf2 plugin by creating a plugin with exactly the same structure. DITA open toolkit’s default pdf plugin – org.dita.pdf2 – contains a collection of stylesheets and attribute sets. DITA open tool kit connects everything together only when you generate the pdf output. we can’t see the result page layout till then. Tweaking the attribute sets and xsl is the way to customize output!
Most of the time we will be looking into following folders
- attrs: This folder has collection of attribute sets that define how the element should appear.
- xsl: This folder has collection of stylesheets that define how the element should be processed
Customise only what you want
Attribute sets are grouped by element type lists, links, tables and so on. We need to redefine only those attribute sets that we want to customize by putting them into respective attrs and xsl folders of the com.mycompany.website-ug plugin. Rest of the elements will remain as it is and will be processed as per the org.dita.pdf2 plugin.
For example, to change the header and footer color of your pdf output you will be required to do following.
Copy required xsl files
Copy layout-masters-attrs.xsl and layout-master.xsl files from org.dita.pdf2 into respective attrs and xsl folders of com.mycompany.website-ug.
Inform custom.xsl about those files
You need to inform DITA open toolkit about what you are customizing. So, you need to add an xsl:import statement into custom.xsl file.
You have custom.xsl file in both the folders: attrs and xsl. Open them one by one and add xsl:import statement respectively as shown in the figure below.
Now, you are ready to change the appearance of attribute sets defined in the layout-masters-attrs.xsl
Open layout-masters-attrs.xsl using Notepad ++ like editor. Make sure to open the file from com.mycompany.website-ug folder.
Locate the attribute set with name “region-before”.Lets create an xsl attribute with name background-color for the region-before attribute set.
Save the layout-masters-attr.xsl and generate the pdf output using newly created plugin.
Run startcmd.bat from the DITA open toolkit’s install directory and enter the following command.