Page X/Y: Calculating the Total Page Count

Valid from List & Label 4
Starting with List & Label 11 you can use the TotalPages$() function to get the total number of pages. Please note that a placeholder will be displayed in the designer that is replaced by the actual value during print out. A possible formula for the page number would thus be
"Page "+ Page$() + " of "+TotalPages$()


To get the right result with older versions you have to use the so-called “2-pass technique”. Your application is performing an “invisible” preview print process (without displaying the preview file) just for getting the total page count (by using the appropriate LlStgsys function, see example below). This total page count is then provided as a variable for the second, “real” print process, (e.g. “TotalPageCount”).

We recommend to use LlPrintIsVariableUsed to examine whether this variable has ever been used in the report. If not then you don’t need to perform such a 2-pass printing loop and the whole print process will of course become much more performant.

hStg = LlStgsysStorageOpen("c:\\test\\label.ll", NULL, TRUE, TRUE);
nTotalPageCount = LlStgsysGetPageCount(hStg);
LlStgsysStorageClose(hStg);
IDKBTE000520 KBTE000520