Skip to main content
jfb45671162
Participating Frequently
March 10, 2016
Answered

Dynamic Page Numbering script isn't working on spawned pages?

  • March 10, 2016
  • 1 reply
  • 6515 views

I'm working in Acrobat Pro XI on a 4 page document with a button that allows a template pages to be inserted after page 3.  I created a button for this and it is working fine.  But each page has a text field that is supposed to auto update all of the page numbers.  The code looks like this:

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

calculateNow();

On the four pages visible when the file is opened it is working perfectly; they will update from "Page 1 of 4" to "1 of 5", etc. without any problems.  However, the inserted template pages are very random.  Sometimes the first spawned one will work and say Page 4 of 5 but sometimes it will say Page 0 of 4.  It's worth mentioning that even when it says Page 4 of 5 printing that page shows it saying Page 0 of 4 again.  And any additional pages spawned after that will list a bunch of random numbers out of the correct number of pages.  So it will look like "Page 7, 6, 5, 4, 31 of 9".

I've been looking through a lot of previously asked questions and haven't seen any quite like this. 

This topic has been closed for replies.
Correct answer George_Johnson

If you want to add a new page for each press of the button, you can simplify the code to:

getTemplate("Addittional Collaborators").spawn(numPages, true, false);

but you'll have to add code to correctly set the "page x of y" field values. Post again if you have trouble with that part.

1 reply

Inspiring
March 10, 2016

Where did you place that script exactly? Can you show the code you're using to spawn the template that includes the field that's used to display the "Page 1 of 4" text?

jfb45671162
Participating Frequently
March 10, 2016

I placed the script in the custom calculation portion of a text field.  And I have the spawn template button separate from the "Page x of y" text.  The trigger is Mouse Up and the code is:

var a = this.getTemplate("Addittional Collaborators");

for (var i = 3; i<4; i++)

a.spawn(i, true, false);

try67
Adobe Expert
March 10, 2016

I have a feeling your spawned field names are identical...

On Thu, Mar 10, 2016 at 11:11 PM, jfb45671162 <forums_noreply@adobe.com>