Table of Contents
More Resources
Editing a Footer Template

Edit the custom-xsl.xsl file to add a footer to your main content pages.
You want to add a footer template in the custom-xsl.xsl file (located in cfg/fo/xsl/) to add a custom footer with specific footer text or the page number.
  1. To add a footer, you need to modify the “insertBodyOddFooter” XSL template. The default in org.dita.pdf2 uses the ‘Body odd footer’ variable and shows the footer content and page number:

    Step Information
    < xsl:template name="inserBodyOddFooter"> 
      < fo:static-content flow-name="odd-body-footer"> 
        < fo:block xsl:use-attribute-sets="__body__odd__footer"> 
          < xsl:call-template name="insertVariable"> 
            < xsl:with-param name="theVariableID" select="'Body odd footer'"/> 
            < xsl:with-param name="theParameters"> 
              < heading> 
                < fo:inline xsl:use-attribute-sets="__body__odd__header__heading"> 
                  < fo:retrieve-marker retrieve-class-name="current-header"/> 
                < /fo:inline> 
              < /heading> 
              < pagenum> 
                < fo:inline xsl:use-attribute-sets="__body__odd__footer__pagenum"> 
                  < fo:page-number/> 
                < /fo:inline> 
              < /pagenum> 
            < /xsl:with-param> 
          < /xsl:call-template> 
        < /fo:block> 
      < /fo:static-content> 
    < /xsl:template> 

  2. You’re going to change the template to show some text and the page number.
  3. Anything you want to put in the footer must be contained within the fo:static-content tag. And it is usually convenient to keep the fo:block as well due to the __body__odd__footer attribute-set:

    Step Information
    < xsl:template name="insertBodyOddFooter"> 
      < fo:static-content flow-name="odd-body-footer"> 
        < fo:block xsl:use-attribute-sets="__body__odd__footer"> 
          
        < /fo:block> 
      < /fo:static-content> 
    < /xsl:template> 

  4. To add footer text, you need to access two different variables (for the text and page number) and use the fo:leader to split them on opposite sites of the page.

    Step Information
    < fo:block xsl:use-attribute-sets="__body__odd__footer"> 
      < xsl:call-template name="insertVariable"> 
        < xsl:with-param name="theVariableID" select="'Custom Footer Text'"/> 
      < /xsl:call-template> 
      < fo:leader leader-pattern="space"/> 
      < xsl:call-template name="insertVariable"> 
        < xsl:with-param name="theVariableID" select="'Custom Page Number'"/> 
        < xsl:with-param name="theParameters"> 
          < pagenum> 
            < fo:page-number/> 
          < /pagenum> 
        < /xsl:with-param> 
      < /xsl:call-template> 
    < /fo:block> 
    
    Note:If you want to display the total page count (for example, “Page x of y”), you’ll need to use the Total Page Number guide.
  5. Combine all the code together into the footer template and add it to the custom-xsl.xsl file located at cfg/fo/xsl/:

    Example
    < xsl:template name="insertBodyOddFooter"> 
      < fo:static-content flow-name="odd-body-footer"> 
    
        < fo:block xsl:use-attribute-sets="__body__odd__footer"> 
          < xsl:call-template name="insertVariable"> 
            < xsl:with-param name="theVariableID" select="'Custom Footer Text'"/> 
          < /xsl:call-template> 
          < fo:leader leader-pattern="space"/> 
          < xsl:call-template name="insertVariable"> 
            < xsl:with-param name="theVariableID" select="'Custom Page Number'"/> 
            < xsl:with-param name="theParameters"> 
              < pagenum> 
                < fo:page-number/> 
              < /pagenum> 
            < /xsl:with-param> 
          < /xsl:call-template> 
        < /fo:block> 
    
      < /fo:static-content> 
    < /xsl:template> 
You added your custom footer template to the custom-xsl.xsl file located at cfg/fo/xsl/.
Your custom footer template contains new attribute-sets. See Adding Footer Attributes to define the new attribute and ensure your footer displays correctly.