Access Page Number {#} and Page Count {##} in script

Hey guys,

I don’t know how can I access those variables via script in the designer. Basically I want to have a text box that will be driven by script. There will be different text to display for not last page, and different for last page. Pseudo code below

if ( {#} != {##}) {

display AAA

} else {

display BBB

}

P.S. Ok i know this is possible by setting Sheet configuration and creating Master page for last page, but I really would like to do that in the script if possible

Regards

Tomasz

Hi tomtom,

Unless something has changed that I am not aware of you cannot access the page number/count within a script. That functionality is built into the designer interface from what I gather. The only way I know of is using master pages as you mentioned.

Perhaps a OL dev can shed some light here.

Regards,

S

Can you elaborate on where you placed the text. Is it part of the text flow or does it reside in a box from the master page?

The simplest way to achieve this is by using an Output preset. Then select “Additional Content”. In the Text and Images tab, add the following text:

${var textToDisplay = (page.nr != document.count.pages) ? ‘AAA’ : ‘BBB’; textToDisplay;}

@Erik van den Heuvel

I used Insert Positioned Box on the Contexts/Print/Section 1 (default) and I was trying to give this div a class so I could use it in script.

@Rod

Yeah Rod, that would work, but thinking from maintenance perspective - this is like another layer that developer needs to keep an eye on during development (since this element will not be visible on the design - created on fly).

Accessing Page number and Page count directly from Design would be really helpful

I think I will go for Sheet configuration solution, but of course I will mark Rod’s solution as valid as it may be helpful for someone else

1 Like

I agree this would be useful, it looks like you are trying to do what I am and create an AIMS barcode on the sheets @tomtom