Highlighted

Acrobat DC PRO - add pages - refresh page numbering

Community Beginner ,
Oct 28, 2020

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Look for template and spawn in the Acrobat Javascript Reference.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

57

Likes

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

Acrobat DC PRO - add pages - refresh page numbering

Community Beginner ,
Oct 28, 2020

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Look for template and spawn in the Acrobat Javascript Reference.

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

58

Likes

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
Oct 28, 2020 0
Most Valuable Participant ,
Oct 28, 2020

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Oct 28, 2020 1
Community Beginner ,
Oct 28, 2020

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Oct 28, 2020 0
Adobe Community Professional ,
Oct 28, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Oct 28, 2020 1
Most Valuable Participant ,
Oct 28, 2020

Copy link to clipboard

Copied

... Or manually rename them after importing the pages.

Likes

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
Reply
Loading...
Oct 28, 2020 1
Community Beginner ,
Oct 28, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Oct 28, 2020 0
Adobe Community Professional ,
Oct 29, 2020

Copy link to clipboard

Copied

Look for template and spawn in the Acrobat Javascript Reference.

Likes

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
Reply
Loading...
Oct 29, 2020 1
Adobe Community Professional ,
Oct 28, 2020

Copy link to clipboard

Copied

Hello,

This is very interesting, where you could learn more about Acrobat JS.

Greetings,

WbolanosCo

Likes

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
Reply
Loading...
Oct 28, 2020 0