Skip to content

Page Headers and Footers

Cristian Talau edited this page May 20, 2017 · 4 revisions

First of all, take a look the following image that shows page headers for a PDF generated by the DITA-OT processor without any customization.

images/pdf2_header.PNG

Notice that the chapter title and page number are generated on the page header, in the top-right corner, and they are separated with '|' characters.

You can analyze the default implementation by looking at the org.dita.pdf2/xsl/fo/static-content.xsl stylesheet.

For our customization, we modified the static content generation to do the following:

  • Display the chapter title and page number in the page footer.
  • Render the chapter title on the left side and page number on the right side.
  • Omit the chapter title from the first page since it is already displayed in the center of the page.

You can view all of these customizations by looking at the com.oxygenxml.pdf2.ug/Customization/fo/xsl/static-content.xsl stylesheet.

Page numbering

The PDF produced by the default DITA-OT PDF transformation uses a double-sided page numbering style. This means that chapters will always start on odd numbered pages and blank pages will be added when a chapter does not end on an even page number.

This behavior is useful when you want to print a PDF book, but it can be annoying when you publish the PDF only to be read electronically with a PDF reader application.

This behavior is implemented in XSL-FO by setting the force-page-count="even" attribute on the fo:page-sequence element.

To see the default implementation, search for the __force__page__count attribute set in the org.dita.pdf2/cfg/fo/attrs/commons-attr.xsl stylesheet.

In our customization, we set the force-page-count attribute to auto so that no blank pages are produced. See the implementation in: Customization/fo/attrs/commons-attr.xsl.

Resetting page numbering on first chapter

We decided to use two different styles for page numbering. In the first part of the user manual that includes the Table of Contents, we used Roman numerals, but for the rest of the manual, we reset it to use Arabic digits.

To reset the page numbers in XSL-FO, the initial-page-number attribute should be specified on the fo:page-sequence element.

See the entire customization in the startPageNumbering template from the com.oxygenxml.pdf2.ug/Customization/fo/xsl/commons.xsl stylesheet.

Related information: