Search code examples
xsltxsl-foapache-fop

How to display one or the other information depending on the page number in XSL-FO?


I'm using XSL-FO to create PDF's. Now I have a label that I want to display only on the first page, and another label that I want to display on all other pages, e.g.

Page 1

Last month's balance

Page 2 - n

Previous page's balance

The whole PDF is actually just a simple table, so this isn't about a cover page that stands outside of the data. How can I do it?

See also this related question: How can I sum up some values per page in a table in XSL-FO?


Solution

  • This one can either be achieved using fo:marker and fo:retrieve-marker (from fo:static-content), or with the help of fo:page-sequence-master, that provides different fo:simple-page-master entries for the first page (@page-position="first") and other pages (="rest").

    In the latter case you would need to name static regions on different simple-page-masters differently, and provide an fo:static-content in the fo:page-sequence for each page master.