How to show page number (N of N) using xslt in PDF Report

孤街醉人 提交于 2019-12-01 03:13:53

I solved my problem by following below instructions.

Put a formatting object with an id at the end of the area. You can then do a to the labeled block that appears on the last page of the document. Here's how the markup looks:

<fo:flow flow-name="xsl-region-body">
... Lots and lots of content here
<fo:block id="TheVeryLastPage"> </fo:block>
</fo:flow>

The code creates a block with an id of TheVeryLastPage (a value that's unlikely to be used by anyone), and now you can refer to that id to get the page number of the last page of the document. Here's how the content in the area should look:

<fo:block text-align="end">
Page <fo:page-number/> of 
<fo:page-number-citation 
ref-id="TheVeryLastPage"/>
</fo:block>

When FOP formats this markup, it generates something like "Page 2 of 5".

My reference URL is: http://www.ibm.com/developerworks/xml/tutorials/x-xslfo2/section4.html

glmxndr

You should add an id attribute to your fo:page-sequence element, and then use a page-number-citation-last.

<fo:page-sequence id="my-sequence-id">
  ...
  <xsl:text>Page </xsl:text>
  <fo:page-number-citation />
  <xsl:text> of </xsl:text>
  <fo:page-number-citation-last page-citation-strategy="all" ref-id="my-sequence-id"/>
  ...
</fo:page-sequence>

See the specs: http://www.w3.org/TR/xslfo20/#fo_page-number-citation and http://www.w3.org/TR/xslfo20/#fo_page-number-citation-last

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!