Friday, 19 October 2012

NextReports: Total Pages Number

In documents like PDF sometimes it may be needed to have a Total Pages Number to be shown on every page header or footer.

In version 5.4 a new variable TOTAL_PAGE_NO can be used to accomplish this. This variable is a bit different than all other variables which can be evaluated as the records are read.  TOTAL_PAGE_NO variable can be evaluated only when the document is closed. Because of that, you cannot enter this variable inside an expression and you should always use it standalone.

So, how do you create an expression like "Page 1 of 10" in your header? You have to split this into two elements:
  • an expression for the part that is evaluated as the document is created ("Page 1 of"). In this expression you will use PAGE_NO variable

  • a simple TOTAL_PAGE_NO variable inside a cell near the expression
Your layout with these two elements inside a page header row will look like:

As you see, first cell element is right aligned, while the cell with variable is left aligned. And the pdf result will look like:

1 comment: