Forum How do I...?

Include "Continued on XX" on all pages except the last

damartin
My requirement is to include the text "Continued on Page XX", where XX is the next page number, at the bottom of every page, except of course the last page.

Preferably as well this text will be three lines below the main content on the page rather than be at a fixed position at the bottom of the page. We are displaying non-breaking blocks of data so some pages may end up with more white space at the bottom (up to a third of the page) depending on the the size of the block.

Note that there is also some fixed text which is being printed at the bottom of the page, for which I'm using the footer flow.

To further complicate things, I need to generate a combine PDF, i.e. I will end up with individual PDFs for each person and a combined PDF. Within this combined PDF the requirements are to be applied to the subset of pages for each person. The page numbers are specific to that person and the "last page" refers to each person rather than the PDF as a whole.

thanks

Edited by damartin

mikeday
The attached continued.html document uses a JavaScript function in CSS generated content to put the continued text on every page but the last by comparing the current page number with the total number of pages. (Please note that JavaScript must be enabled for this to work).

If you want the text to appear in the main page body and not the footer then that is more complicated. One approach is to place the document content inside a table and use a repeating table caption that will appear on every page, then use the same script function as before to generate the text for it, as shown in the attached caption.html document.

The final requirement for combining many of these will probably require one further trick of resetting the page counter for each subsection and using target-counter() to reference the page counter of the last page of the section.
  1. caption.html0.7 kB
  2. continued.html0.6 kB
damartin
Thanks very much Mike, Worked like a charm. I can't tell you how much time I've wasted trying to solve this.

For other readers, the solution I used:

I went with the table caption so it is in the document content. The example file caption.html had everything I needed for the individual documents.

For the combined file I used the table as the subsection to reset the page counter (had to give it a class name for the external stylesheet). Fortunately I already had a block of text that only occurs on the last page of each subsection (each individual document). Gave it an ID so I could reference it from the target-counter(). The span in the caption ends up as:
<span style="content: prince-script(continued, counter(page), target-counter(url('#end'), page))"></span>

Note: the javascript (see caption.html) and the span style which calls the javascript function are in the document rather than external javascript/stylesheet references.