I have several <fo:page-sequence/>
, each of them initialize the page number from 1. I am able to get access to the total page number of each fo:page-sequence by using <fo:page-number-citation-last ref-id="page-id"/>
. But how can I sum them up to get the total page number of the entire pdf?
Here is my code:
<xsl:template match="a/b/c//d" priority="50">
<xsl:param name="node" select="."/>
<xsl:choose>
<xsl:when test="count($node/ancestor::c) <= 0 or count($node/ancestor::c[parent::c]/preceding-sibling::c) <= 0">
<fo:page-sequence id="pages-{count($node/parent::c/preceding-sibling::c)}-{count($node/preceding-sibling::d)}" master-reference="pages" format="i">
<xsl:call-template name="header_footer"/>
<fo:flow flow-name="xsl-region-body">
<xsl:next-match/>
</fo:flow>
</fo:page-sequence>
</xsl:when>
<xsl:otherwise>
<fo:page-sequence id="pages-{count($node/parent::c/preceding-sibling::c)}-{count($node/preceding-sibling::d)}" master-reference="pages" initial-page-number="{if ($node/preceding-sibling::d) then 'auto' else '1'}" format="1">
<xsl:call-template name="header_footer"/>
<fo:flow flow-name="xsl-region-body">
<xsl:next-match/>
</fo:flow>
</fo:page-sequence>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The xml strucutre is:
<a>
<b>
<c>
<c>
<d/>
<d/>
...
</c>
<c>
<d/>
<d/>
...
</c>
...
</c>
</b>
</a>
Now I can get each page-sequence's total page numbers by using
<fo:page-number-citation-last ref-id="pages-0-end"/>
<fo:page-number-citation-last ref-id="pages-1-end"/>
<fo:page-number-citation-last ref-id="pages-2-end"/>
...
But how can I sum the value of all total page numbers for each page-sequence and get a total page number for the entire pdf?
You could use the axf:physical-page-number
extension (see https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#axf.physical-page-number) to get the physical page number of the last page.
You might, though I've never tried it, be able to use axf:physical-page-number
in combination with axf:orgin-id
to get the number of pages between two FOs.