How to control the PDF page counter?
Generally, JustOn prints the page number for produced PDF files. The templates by default include the pattern [PageLabel] [PageCounter] [OfLabel] [NumberOfPages] (see Built-In Placeholders) in the field Info Left (hidden on the first page, see PDF Contents). This produces a string like, for example, Page 2 of 4 in the top left corner of the page starting with the second page of a document.
Your business may require to modify the page counter display – move it to another area on the page or change a label. Assume, for example, you want the page counter on the page bottom and "of" replaced with a slash character.
To this end, proceed as follows:
- Open the template to be edited.
- In the Header & Footer section, delete the string
[PageLabel] [PageCounter] [OfLabel] [NumberOfPages]from theInfo Leftfield and insert it in theFooterfield. -
In the Overrides section, add the following JSON expression to the
Override Labelsfield:{ "Calculated": { "OfLabel": "/" } }
Since the footer is printed on every page of the PDF file, the page counter will be visible from page 1, and display like Page 1 / 2 for a two-page document.
With v3 templates
The approach above applies to standard templates and to Liquid templates on the v2 engine. On the v3 renderer, the page counter is not driven by the Info Left/Footer fields or placeholders. Instead, it is defined in the Liquid file using an @page margin box with the counter(page) and counter(pages) functions:
@page {
@bottom-center {
content: "Page " counter(page) " of " counter(pages);
}
}
Adjust the content string to move or relabel the counter, for example, content: "Page " counter(page) " / " counter(pages);. For details, see Defining Headers, Footers and the Page Counter.