More Resources
Table of Contents
More Resources
Updating the ‘Custom Page Number’ Variable

Update the custom-xsl.xsl and en.xml to include the total number of pages in your page number variable.
You already calculated the total number of pages using the procedure in Calculating the Total Number of Pages.
You want to display the total number of pages in your PDF output.
  1. Now that you have a value for the total page number, you need to edit your call to the insertVariable template (located in cfg/fo/xsl/custom-xsl.xsl) to pass it in. The following example modifies the footer block from Editing a Footer Template. If you want to add this to the header, you can change the call to call-template in your header block.

    Step Information

    Add the following reference into the < totalpages> element within the parameters that are passed into the insertVariable call-template: 

    < fo:page-number-citation-last ref-id="last-page-id"/> 

    Expected Result
    < 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> 
          < totalpages> < fo:page-number-citation-last ref-id="last-page-id"/> < /totalpages> 
        < /xsl:with-param> 
      < /xsl:call-template> 
    < /fo:block> 

  2. Now, you need to update your variable definition in cfg/common/vars/en.xml to:

    Step Information
    < variable id="Custom Page Number"> 
      Page < param ref-name="pagenum"/>  of < param ref-name="totalpages"/> 
    < /variable> 

Your page number should now appear as “Page x of y:”. Here’s an example of the output: