Skip to main content
sebastianb99835257
Inspiring
February 21, 2018
Answered

Page Numbers with Spawn Pages

  • February 21, 2018
  • 1 reply
  • 3331 views

Hello,

I have a 1 page PDF form which I have set to be a template. I have added in page numbers up in the top right of the header (page 1 of n). I have also added a button that when pressed will execute the following code:

var t = this.getTemplate("Template");

t.spawn(event.target.page + 1, true, false);

The problem is when the button to duplicate the pages is pressed the page numbering remains "Page 1 of 1" on both of the pages.

Is there some code I can add to the button that will tell the page numbering to update after I have added the button is pressed and the new page added?

Cheers,

Seb.

This topic has been closed for replies.
Correct answer try67

You'll need to use fields for that.

They can have the following calculation script:

event.value = "Page " + (event.target.page+1) + " of " + this.numPages;

And after spawning the pages call the calculateNow method to update them.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 21, 2018

You'll need to use fields for that.

They can have the following calculation script:

event.value = "Page " + (event.target.page+1) + " of " + this.numPages;

And after spawning the pages call the calculateNow method to update them.

sebastianb99835257
Inspiring
February 21, 2018

Hi Try,

That's worked quite nicely. It actually works now and also looks identical to the header after I made the field read only so that's good.

Just wondering what the point of the calculateNow method was as it currently works without using this bit of code.

Thanks mate.

try67
Community Expert
Community Expert
February 22, 2018

I was not sure if the spawning command will cause the calculation events to

trigger, so I thought it's better to force it, to make sure they present

the correct value.

If you see it's not needed you can remove it, of course.

On 22 February 2018 at 00:52, sebastianb99835257 <forums_noreply@adobe.com>