Skip to main content
Participant
October 28, 2020
Answered

Acrobat DC PRO - add pages - refresh page numbering

  • October 28, 2020
  • 1 reply
  • 1565 views

Hi there,

 

I have found many replies to this kind of issue but none helped me so far.  So here is what i work with and what i did so far.

 

I have a form of 1 page (intropage). To this 1st page can be added 3 different templates.  

- interior checkup

-exterior checkup

- final page (for signatures, annotations etc)

 

I have added 3 buttons on each template with javascripts to "add" the page model, when needed.

The javascript looks like this: 

this.insertPages({nPage:this.numPages-1, cPath:"MODELNAME.pdf"});  

The "Modelname" is for showcase here, I use the specific file name of the int/ext/final page.

 

Depending of the situation, I need my first page and, for this example, 4 interior check templates and 3 exterior check templates -  and of ourse the final side for signing. 

 

Actually my page numbering is scripted in a text field (custom calculation) as follows :  

var pnum = this.pageNum+1;
var numpag = this.numPages
event.value = pnum + " / " + numpag;

 

A Document JS is added: 

this.calculateNow();

 

A checkbox is added to each template to "trigger" the calculation, so at the end of editing, i check it,

the field value is changed ==> this makes the calculation script "run" and "refreshes the page numbering (at least, thats how i understood it in the forums.)

 

My guess : the field names for page calculation are not unique. As I sometimes need 5x interior template and let's say additionnally 8x the exterior template - I have 13 identical fieldnames on multiple pages and the scripts start bugging. 

 

What happens ?  When i click the checkbox on page 5, if gives me page 5/5 (wich is correct) but every page will now have this page numbering.

 

I'm a bloody user who builds a form with some extra features to add pages when needed.  So far, this was my idea to get to the right solution. Maybe there is a completely other way to do so ? Or somebody has the script-solution i need because of identical fieldnames ?

 

I already present you my apologies for eventual major logical bugs in this post. And thank you for your patience for ready my post.

 

Many thanks for your help & time 

 

Tom

This topic has been closed for replies.
Correct answer Bernd Alheit

Thank you for all the feedbacks and suggestions.  I know that i can rename the fields manually but when the file is in use and the form is filled, it's clear that when i have 12 additionnal pages, renaming the fields while filling in the form isn't the "smoothest" solution. I was hoping for some kind of alternative, that renames the fields after spawning when fieldnames are identical but I guess i was expecting a bit too much.  Again - i apologize for my high expectations. You can smell that i am a bloody "user" who's just looking for solutions in a messy template.

 

Anyway, thank you very much for your kindness and efforts. I really appreciate !  

 

Have a good day and stay healthy.

 

Tom


Look for template and spawn in the Acrobat Javascript Reference.

1 reply

try67
Community Expert
Community Expert
October 28, 2020

This line is incorrect:

var pnum = this.pageNum+1;

Change it to:

var pnum = event.target.page+1;

 

Of course, each field must have a unique name for it to work.

Tom5CF2Author
Participant
October 28, 2020

Thank you for the fast feedback, I'll change the JS right away.

For the unique fieldname:  What would you suggest me to do when i have to import 3x the same template ?

Thank you in advance.

Bernd Alheit
Community Expert
Community Expert
October 28, 2020

You can use template pages. When you spawn the template pages you can rename the fields.