• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Using forms text fields to dynamically number spawned pages in Acrobat 11 pro

New Here ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

I have been trying to get acrobat to dynamically number pages in a worksheet that spawns additional pages from templates based on user responce to questions. I have created a uniquely named text field on each page with a custom calculation script to populate each field. So far nothing I have tried has worked correctly. It will number the templates correctly but once hidden and spawned it fails.

 

I have attempted the below scripts: 

------- Attempt 1-------

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

calculateNow();

Result: Same page number on every page with correct total page count

 

------- Attempt 2-------

this.getField("Page Count1").value=this.pageNum+1 +" of "+this.numPages;
calculateNow();

Result: Required uniqe code for every text field (86) but resulted in same page count on every page with correct total pages

 

------- Attempt 3-------

event.value = util.printf("Page %d of %d", event.target.page+1,this.numPages);
calculateNow();

Result: Page count illogical ("-2456") with correct total pages

 

------- Attempt 4-------

event.value="Page "+(this.pageNum+1)+" of "+this.numPages;
calculateNow();

Result: Page count illogical ("-1,20") with correct total pages

 

------- Attempt 5-------

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

Result: Page count illogical ("-1,20") with correct total pages

 

 

TOPICS
PDF forms

Views

772

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

 

The calculation script on a template field is run before the template is fully instantiate. At that time the page number for a hidden template is -1. To get the fields to update property, run "calculateNow()" after the spawn function, not in the calculate script. Actually its a really, really bad idea to put "calculateNow()" in a calculate script. Good way to create infinite feedback.

 

In fact, I would avoid using the calculate script altogether. Instead add code after the spawn to find the page number fields on each page and fill them with the proper numbers. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

Excellent idea. I'll give this a try first thing in the morning. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Not too great with script but where do mean to add the code to calculate the pages? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

LATEST

It's not clear what you are asking about. Are you using templates? Templates add pages to a PDF, so the page numbers change. The poster  on this thread has a script that spawns new pages with a page templates. The code for setting the new page numbers needs to be at the end of that script, i.e., after the new page(s) are spawned.   

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines