0

How to identify PDF that will have a single page or more pages in XSL?

I have a footer that shows the current page number and total page number and has a requirement to not display the text(Page 1 of lastPage) in footer if the page of PDF has a single page.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:java="http://xml.apache.org/xslt/java" xmlns:str="http://exslt.org/strings"
    exclude-result-prefixes="fo">
  <xsl:template match="/">
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simpleA4"   page-height="29.7cm" page-width="21cm" margin-top="0.5cm" margin-left="0.7cm" margin-right="0.7cm" padding-right="0.3cm">
          <fo:region-body region-name="xsl-region-body" margin-top="3.8cm" margin-bottom="1.5cm" />
          <fo:region-before  region-name="xsl-region-before" margin-top="2.2cm" extent="5in" />
          <fo:region-after region-name="xsl-region-after"  extent=".8in" />
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simpleA4">

        <fo:static-content flow-name="xsl-region-before">
          <fo:block>        
          </fo:block>
        </fo:static-content>
   
        <fo:static-content flow-name="xsl-region-after">
          <fo:block>
            <fo:leader leader-length="100%" leader-pattern="rule" rule-style="solid" rule-thickness="0.9px" />
          </fo:block>
          <fo:block font-size="10pt" font-weight="normal" text-align="center">
            Page
            <fo:page-number />
            of
            <fo:page-number-citation ref-id="lastPage" />
          </fo:block>
        </fo:static-content>
 
        <fo:flow flow-name="xsl-region-body">
          <fo:block>
            body 
          </fo:block>   
          <fo:block id="lastPage" />
        </fo:flow>

      </fo:page-sequence>
    </fo:root>
  </xsl:template>
</xsl:stylesheet>

Is there any inbuilt function or tag available that gives me the last page number in xsl-region-after?

Darshana
  • 601
  • 2
  • 9
  • 20

0 Answers0