These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Auto numbering spawned pages

jimratajski
Registered: Apr 26 2006
Posts: 13

I have a series of Acrobat forms that have hidden page templates. I would like to automatically number the pages if/when these pages are spawned into the document. The Header/Footer functionality only works with existing pages and does not update when pages are spawned. I am looking to add the Page ? of ? format. Can you help with the Javascript necessary to achieve this? I haven't yet been successful in finding examples of this type of thing on the web. Is it possible?

My Product Information:
Acrobat Pro 8, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
What you are asking for is very tricky. Since you are spawning and possibly deleting document pages the Page numbers any and all document pages could change. Setting the number a spawn time won't work, it has to change whenever a page is inserted anywhere in the doc.

So, what you need is a form field to display the number. The form field and be dynamically updated from JavaScript at anytime. Now here's the tricky part. You need to select an event on which to do the update. I'm pretty sure the calculate event will work. It should get called when the page is spawned because new fields are being added to the form, but you'll have to do some testing to be sure. Here's the code for setting the page number.

event.value = util.printf("%d of %d",event.target.page,this.numPages);
Of course, each page number field will have to have a unique name. If the spawn function is not set to rename fields you'll need to figure out a different methodology.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script