PDF Plugin Creation – Part 4

Let’s now work on the footers. I will be focusing on just the body footers, but you can customize the footers for all the different parts of the book, i.e. the frontmatter, the table of content, etc.

1. Footers

I will create two styles of footers, one for the odd pages, and another for the even pages.

1.1 Create a Background

In Photoshop, create a file with the following settings. I will be adding a color gradient from left to right for the even pages, and from right to left for the odd pages. These two graphics will be named footer-even.png and footer-odd.png. Place them in the artwork folder.

1.2 Add the Background to static-content.xsl

Open static-content.xsl, located in com.client.pdf-reg/xsl/fo. Replace <fo:block xsl:use-attribute-sets="__body__odd__footer"> with:

<fo:block xsl:use-attribute-sets="__body__odd__footer" background-image="./Customization/OpenTopic/common/artwork/footer-odd.png" background-position-horizontal="center" background-repeat="no-repeat">

Replace <fo:block xsl:use-attribute-sets="__body__even__footer"> with:

<fo:block xsl:use-attribute-sets="__body__even__footer" background-image="./Customization/OpenTopic/common/artwork/footer-even.png" background-position-horizontal="center" background-repeat="no-repeat">

1.3 Page Number

As you can see, the background looks good, but the rest, page number and metada is not right. In static-content.xsl, search for <fo:page-number>. Replace it on the Odd Footer section with:

<fo:inline padding-right="15mm"><fo:page-number/></fo:inline>

And on the Even Footer:

<fo:inline padding-left="15mm"><fo:page-number/></fo:inline>

This will display the page number 15mm to the edge of the page so it looks better.

On the Odd Footer section, comment the line <fo:retrieve-marker retrieve-class-name="current-header" />, which places the chapter title in the footer. Do not delete it, as we need it for reference on how to place metadata content.

On the Even Footer section, comment the line <xsl:apply-templates mode="dita-ot:title-metadata" select="/" />, which places the title of the book in the footer.

1.4 Chapter Name

On the odd pages, I want the chapter name back in there, in white, and on top of the background. It can’t be in the same block as the page number, because the page number will move it’s initial position if the number is 2 digits, 3 digits, or more. I can achieve this by using a floating block, using <fo:block-container> as follows:

<!--Chapter Name-->
      <fo:block-container xsl:use-attribute-sets="__body__odd__footer" height="5mm" width="100mm" top="271.5mm" bottom="auto" left="90mm" absolute-position="fixed" border-width="0pt" border-style="solid"><fo:block color="white"><fo:retrieve-marker retrieve-class-name="current-header" /></fo:block></fo:block-container>
<!--End Chapter Name-->

1.5 Result

2. Start Each Chapter on its Own Page

I would like each chapter to start on a new page, not as show below.

2.1 Use the page-break-before attribute

Open commons-attr.xsl, located in com.client.pdf-reg/cfg/fo/attrs. You will add <xsl:attribute name="page-break-before">always</xsl:attribute> to the topic.title attribute set.

This adds a break before each chapter begins, which serves our purpose.

Note: topic.title corresponds to each chapter, topic.topic.title is the subchapter, so on and so forth.

2.2 Result

3. Formatting Tables

I would like the top row of my table to have a color background. I also would like the font color to be changed to white.

3.1 Use background-color and color Inside thead.row.entry

Open tables-attr.xsl, located in com.client.pdf-reg/cfg/fo/attrs. Look for the section that corresponds to thead.row.entry. Replace <xsl:attribute name="background-color">inherit</xsl:attribute> with <xsl:attribute name="background-color">#5F2F83</xsl:attribute>.

Add <xsl:attribute name="color">white</xsl:attribute> to the same section.

3.2 Result

4. Further Reading and Next Parts

By now, you should have a very solid idea on how to customize everything else in your PDF.

I recommend these books that go a lot deeper into the subject:

I am planning on coming up with more parts, as I work with real life client customizations. Keep in mind that I will not be using the dita sample that I have been using, and that I will have to blur some things depending on the content. There will also not be any kind of continuity, as I will show things as I work on them.

Leave a Reply