1
votes

I need to insert in the header the Page number, like Page x of n. It should be something simple, but I can not get it to work.

I've tried.

<fo:page-sequence initial-page-number="1">
  <fo:static-content flow-name="xsl-region-after">
<fo:block>Page <fo:page-number/> of
<fo:page-number-citation ref-id="theEnd"/>    </fo:block>
  </fo:static-content>
</fo:page-sequence>

With the xmlns:fo="http://www.w3.org/1999/XSL/Format namespace and in the end of the document

Any help would be appreciated.

Thanks

2
in the end of the document <fo:block ref-id="theEnd"/> - user2867474
you must have more content than that, otherwise you should get nothing. A page-sequence cannot just have only static-content - Kevin Brown

2 Answers

1
votes

I would assume you mean that you actually have content in the page as in:

<fo:page-sequence initial-page-number="1">
  <fo:static-content flow-name="xsl-region-after">
   <fo:block>Page <fo:page-number/> of
    <fo:page-number-citation ref-id="theEnd"/>    </fo:block>
   </fo:static-content>
   <fo:flow>
       <fo:block>I have a lot of content here ...</fo:block>
       <!-- and even more here -->
   </fo:flow>
 </fo:page-sequence>

Then you can use an empty block at the end as suggested with:

 <fo:block id="theEnd"/>

Or you can also use (if your formatter supports it):

 <fo:flow id="myDoc">...

And use:

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

This second method eliminates the need to drop a special block at the end that is empty. Also note that this works for documents with one page-sequence, if you have documents with multiple page-sequence elements then you would need to match "id" and "idref" with something unique for each page-sequence.

0
votes

The element you're referring to needs to have an id attribute, not ref-id:

<fo:block id="theEnd"/>