Highlighted

Copy existing page and rename fields to automatically add a new amount

Community Beginner ,
Sep 28, 2020

Copy link to clipboard

Copied

Hi all,

 

I'm new to Adobe Acrobat and JavaScript and I'm looking for a solution for a problem. So here's what I did so far:

I used a PowerPoint file and turned it to a pdf. On page 16 is a table where I added some fields in Acrobat.

Page 16 is a template called "Anlage". You have four lines where you can chooce products from a drop down menu (fields Product 1 to Product 4) and enter the amount per product (fields amount 1 to amount 4). At the bottom there's a field called "total" where I add all four amounts. So far, so good. In case you have to choose more than four products I use the following javascript on a button to copy the page (via template) 

 

var t1 = getTemplate("Anlage");
t1.spawn({nPage: numPages, bRename: true, bOverlay: false});

 

Here's what I couldn't solve so far:

How can I add the new page after the existing page 16?

How can I add the "new" amounts to the existing ones so I get a "new" total amount from the products of page 16 and the products of the new page?

 

Unfortunately I can't upload the pdf because it's from my employer, so I tried to describe the problem as good as I could.

 

Any ideas how to solve my two problems?

 

Best regards

Chris

TOPICS
General troubleshooting, How to, PDF forms

Views

26

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

Copy existing page and rename fields to automatically add a new amount

Community Beginner ,
Sep 28, 2020

Copy link to clipboard

Copied

Hi all,

 

I'm new to Adobe Acrobat and JavaScript and I'm looking for a solution for a problem. So here's what I did so far:

I used a PowerPoint file and turned it to a pdf. On page 16 is a table where I added some fields in Acrobat.

Page 16 is a template called "Anlage". You have four lines where you can chooce products from a drop down menu (fields Product 1 to Product 4) and enter the amount per product (fields amount 1 to amount 4). At the bottom there's a field called "total" where I add all four amounts. So far, so good. In case you have to choose more than four products I use the following javascript on a button to copy the page (via template) 

 

var t1 = getTemplate("Anlage");
t1.spawn({nPage: numPages, bRename: true, bOverlay: false});

 

Here's what I couldn't solve so far:

How can I add the new page after the existing page 16?

How can I add the "new" amounts to the existing ones so I get a "new" total amount from the products of page 16 and the products of the new page?

 

Unfortunately I can't upload the pdf because it's from my employer, so I tried to describe the problem as good as I could.

 

Any ideas how to solve my two problems?

 

Best regards

Chris

TOPICS
General troubleshooting, How to, PDF forms

Views

27

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
Sep 28, 2020 0
try67 LATEST
Most Valuable Participant ,
Sep 28, 2020

Copy link to clipboard

Copied

1. Change the nPage parameter to 15.

2. You will need to write a calculation function that takes it into account. Fortunately, the field names on a spawned page are predictable and consistent with each other, so this can be achieved with some relatively-simple string manipulations.

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...
Sep 28, 2020 0