Skip to main content
Participant
April 9, 2019
Question

How to add automated calculated fields.

  • April 9, 2019
  • 2 replies
  • 11850 views

Hello Everyone,

I am currently using Adobe Acrobat XI Pro and am having trouble adding automated calculated fields. The formula I am looking to add is very simple. This is the general framework I am looking to create:

A: Total cost of computer ___________________ (dollar amount inserted by user)

B: Less 20% _____________________________ (formula would automatically multiply the dollar amount entered by 80%)

C: Total loan amount _______________________ (A minus B will be automatically computed)

😧 Amount of terms ________________________ (term quantity will be entered by user)

E: Biweekly deduction ______________________ (C divided by D will be automatically computed)

As you can see, I would like three of these fields to be automated, making the user experience with the PDF file a smooth and seamless function.

Thank you in advance for any guidance provided.

This topic has been closed for replies.

2 replies

Participant
March 6, 2020

code for field B:   this.getField("less20").value = this.getField("totalCost").value * 0.20;   

code for field C:    this.getField("totalLoan").value = this.getField("totalCost".value - this.getField("less20").value;

code for field E:

if (!Math.trunc) {
Math.trunc = function (v) {
return v < 0 ? Math.ceil(v) : Math.floor(v);
};

}

this.getField("biWeeklyDed").value = Math.trunc(this.getField("totalLoan").value  / this.getField("termQty").value);

 

TMacFarlane
Participating Frequently
August 12, 2020

This worked for me! Thanks very much—just needed to figure out how to write the code, and this post showed me what the JS formatting would look like in the Custom field. Thanks for this help!

Thom Parker
Community Expert
Community Expert
April 10, 2019

Here's an article on using PDF form calculations.

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

I think you could do your calculations with "Simplified Field Notation"

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
April 11, 2019

Thank you for responding Thom. Unfortunately my Content Editor only shows the following actions:

  • Edit Text & Images
  • Add Text
  • Add Image
  • Export File to...

More Content

  • Add or Edit Link
  • Add Bookmark
  • Attach a File

Maybe I need to download add-ins?

Thom Parker
Community Expert
Community Expert
April 11, 2019

So first you need to add form fields to the page. To do this you need to click on the "Prepare Form" tool, not the "Edit PDF".

Theses videos explain a lot, even though they are for older versions.

Free Video Content & Full Listing of Available Videos

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