Skip to main content
Known Participant
December 15, 2016
Question

Template page number

  • December 15, 2016
  • 3 replies
  • 1465 views

Can someone help me out with this? I have a button which places a new page in the doc, no problem. What I was wanting to do is to add a page number in the lower right hand side of the new page. As the doc grows so would the page numbers. The template places new pages after the first page so the number should be like so, 2, 3, 4, 5, 6 etc. Is there a javascript to this? If so, where can I view it and where would I place it? Thank you.

This topic has been closed for replies.

3 replies

JR Boulay
Community Expert
Community Expert
February 16, 2017

I mean : template page = spawned page

Acrobate du PDF, InDesigner et Photoshopographe
MM2016
Known Participant
February 16, 2017

It does kind of work but per my original question there are bugs. How can I display the correct page number on the last page as this shows i.e. 0 of 4?

...and if I delete one or more pages, how can I display the correct (recalculated) page numbers, i.e. page 1 still shows page 1 of 4 even if I deleted a page? It should show page 1 of 3.

Thanks

JR Boulay
Community Expert
Community Expert
December 19, 2016

This is because calculations occurs before spawning/deleting pages.

You must add 3 lines to your script, so calculations will be made after spawning/deleting, not before.

this.calculate = false;

// here is the script that spawn/delete pages

this.calculate = true;

this.calculateNow();

Acrobate du PDF, InDesigner et Photoshopographe
pdfUser1Author
Known Participant
December 20, 2016

Like so?

On static pages:

event.value = (event.target.page + 1);

this.calculate = false;

On template pages:

event.value = (event.target.page[1] + 1);

this.calculate = true;

this.calculateNow();

Did I get it right?

JR Boulay
Community Expert
Community Expert
December 20, 2016

No, leave calculations events untouched.

this.calculate = false;

// here is the script that spawn/delete pages when the end user clic on the button

this.calculate = true;

this.calculateNow();

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
December 18, 2016

Hi.

Place this script as a calculation script in a text field on each page:

On static pages:

event.value = (event.target.page + 1);

On template pages:

event.value = (event.target.page[1] + 1);

Acrobate du PDF, InDesigner et Photoshopographe
pdfUser1Author
Known Participant
December 19, 2016

Hi JR, I tried the lines of script you provided. They kinda work, but I was hoping to do is, to add a new page from the template. The page number should be added at that point. Is there a way to not have to add a new text field on each static pages? Then when I delete a page that I create from the template the number remains the same, it doesn't update with a new page number. Example: if I click the button to add a new page, a page number gets placed on the new page, let's say page 4, then when I add additional pages and delete page 4, all the pages keep the page numbers they were assigned. Is there a way to make the page numbers update to the new page number? Am I doing something wrong? Or not doing something right?