Creating Page Numbering

The Page Numbering feature enables you to create design elements that incorporate page numbering information. The page numbering information can be formatted using JavaScript logic to display as plain text or in a barcode.

In case of a variable number of pages document, the final number of pages differs between recipients (such documents may be created using autoflow or page visibility). If you wish to display in your design an element which depends on the final number of pages, you cannot simply create a static element. Using this feature, you can easily achieve this.

This feature supports master pages. Hence, if the page-numbering element is repeated across all pages of the document, it is recommended that you add it to the master page instead of on each page. Note that the correct page number will be shown only on the final output, and not when previewing the document.

For example, to display at the bottom of each page the text Page x out of n, you will need to create a text box and enable the page numbering text as follows:

Page numbering logic can be implemented using a barcode, text, visibility or page visibility.

Barcode

Page numbering barcode (video)

If you wish to show in the design a barcode which includes the page index or count information (for example, to be used by an inserter), use the selection tool to select the image box, right click it, and then select Dynamic Content > Page Numbering Barcode.

Note that you can also select multiple graphic frames and apply the page numbering barcode feature to all the selected frames in one step.

The following example shows the function that will be translated to a QR code. This function will ensure both page index and page count have exactly 3 digits each. For example, if the page was #3 of a total of 15 pages, the QR Code in the example below would include the value "003015".

Note that you can select the barcode type and properties.

In case you need to use a content object value in addition to the page numbering, select it from the state Content Object list, and in the function use state.adorValue.

Text

Page numbering text (video)

If you wish to show in the design a text value based on the number of pages in the document, use the selection tool to select the text box, right click it, and then select Dynamic Content > Page Numbering Text.

Note that you can also select multiple text frames and apply the page numbering text feature to all the selected frames in one step.

The following example shows the JavaScript function for defining the Page x out of n text.

In case you need to use a content object value in addition to the page numbering, select it from the state Content Object list, and in the function use state.adorValue.

Visibility

Page numbering visibility (video)

You can define whether an element (image or text) in your design will or will not be visible, depending on the final number of pages and the page on which the element is placed. To do so, use the selection tool to select the image or text box, right click it, and then select Dynamic Content > Page Numbering Visibility.

Note that you can also select multiple text or graphic frames and apply the page numbering visibility feature to all the selected frames in one step.

For example, display an element only on even pages.

In the following example, the selected image/text will be displayed on even pages only:

In case you need to use a content object value in addition to the page numbering, select it from the state Content Object list, and in the function use state.adorValue.

Page visibility

Page numbering page visibility (video)

You can define whether a page in your design will or will not be visible, depending on the specific logic that you set. Page numbers will be adjusted accordingly.

Section filler pages example

Let's take for example a booklet that has multiple chapters. Each chapter is a section. We wish each section to start on an odd page. Since the length of sections may be dynamic, we may need to add an extra blank page at the end of the previous section in order for the new section to start on an odd page.

To do so, add a blank page at the end of each section (filler page), which will be visible only if needed. Then, select this page in the Pages panel (or multi-select all blank pages) or in the document, and add visibility logic by right-clicking and selecting Dynamic Content > Page Numbering Page Visibility.

In this example, blank pages will be visible only if they appear on an even page so that the next section will start on an odd page.

Document filler pages example

Let's look at another example, in which you are preparing a booklet with front and back cover pages. Each sheet in the booklet includes 4 pages, therefore we would like the booklet to reach multiples of 4 pages. However, the number of pages in the booklet may be dynamic. For those records that are short in pages and do not reach multiples of 4, we should add blank pages, for example at the end of the booklet.

To do so, add 3 pages - blank or designed - at the end of the booklet or elsewhere (filler pages), which will be visible only if needed. Then, select these pages in the Pages panel or in the document, and add visibility logic by right-clicking and selecting Dynamic Content > Page Numbering Page Visibility.

In this example, filler pages will be visible only if they are needed to complete multiples of 4.

State variables

The JavaScript function that you define to format the page numbering text or barcode has access to several state variables that contain information about the record number and page number for you to use. Hover the mouse over the info icon to view the list of available state variables.

state.adorValue

The state.adorValue variable will contain the value of the content object (selected from the state Content Object list) for the current recipient being printed.

An example of using the state.adorValue value could be to have an inserter include an additional item from the inserter tray based on content object logic. For example, if the recipient data included a field which indicates that the recipient requested a brochure,  then the state.adorValue value could be used to add the required code into a barcode to instruct the inserter to include the   brochure from the inserter tray into the envelope, in addition to the document being printed.

state.pageIndex

The state.pageIndex variable will contain the page index for the current recipient being printed. When dynamic printing multiple records, the state.pageIndex is reset for each recipient. For example, if 2 pages are printed for each recipient, the first page of the document for recipient #3 will have a page index of 1 even though it will be page #5 in the output print file.

state.pageCount

The state.pageCount variable will contain the total number of pages for the current recipient being printed. When dynamic printing multiple records, the state.pageCount is reset for each recipient.

state.runRecordIndex

The state.runRecordIndex variable will contain the index of the record in the current print run. For example, for the first record the state.runRecordIndex will be 1. When dynamic printing multiple records, the state.runRecordIndex will increment for each record. In most cases, record and recipient are equivalent. However, in some cases, such as Skip policy, the record index and the recipient index may differ.

state.runPageIndex

The state.runPageIndex variable will contain the index of the page in the current print run. For example, for the first page the state.runPageIndex will be 1. When dynamic printing multiple records, the state.runPageIndex will increment for each page in the print run and is not reset for each new recipient like the state.pageIndex.

An example of using the state.runPageIndex value could be for error checking when using an inserter. Most inserters use a repeating count sequence of 0 to 7 or 0 to 9 in their barcode to check for any missing pages or pages out of sequence. Using the state.runPageIndex with the JavaScript modulo operator would make it simple to add a repeating number sequence to the page numbering barcode.

State run information considerations

When using the state.runPageIndex and state.runRecordIndex variables, it is not possible to use the Copies Per Record (must be set to 1) and the uProduce Turbo mode (the "Use only single instance" option is required).