Skip to main content
jfb45671162
Participating Frequently
Mar 10, 2016 9:34 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
George_JohnsonCorrect answer
Inspiring
Mar 10, 2016 11:08 PM UTC

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.

22 replies

Inspiring
Mar 10, 2016 10:05 PM UTC

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?

Translate
jfb45671162
Participating Frequently
Mar 10, 2016 10:10 PM UTC

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);

Translate
try67
Community Expert
Community Expert
Mar 10, 2016 10:17 PM UTC

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

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

Translate