Customise pdf output from DITA open toolkit

Customise pdf output from DITA open toolkit
Customising header background DITA to pdf

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-

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 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

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 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.


Java -jar lib/dost.jar /i:samples/taskbook.ditamap /outdir:. /transtype:websiteUG

Krishna Meet is a software scientist having core interest in analytical dashboards. Majority of her career span was into tech-writing and UX-design. However, she thrives by intersecting multiple skill-sets : SQL & NOSQL databases, business analysis, and UX design. She is a voracious reader and possesses Masters degree in Computer Science. Her interest in agile methodologies and user-centered design has landed her a techno-functional role at Brevitaz.


Leave a reply

Your email address will not be published. Required fields are marked *