How to add automated calculated fields.
Copy link to clipboard
Copied
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)
D: 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.
Copy link to clipboard
Copied
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"
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Hey Thom,
This is what my Tools section looks like. I'm assuming it is an older version which is causing my confusion. What would the steps be to find "Prepare Form" and to then add the Simplified Field Notation?
Thank you in advance!
Copy link to clipboard
Copied
Click on the "Forms" tool, then select "Edit.
This will display a toolbar for adding fields. Fields placed on the form will be outlined the fields with the field names visible. Double click on a field to display the properties dialog, where you will be able to add actions and scripts to the field.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
I see! Thank you. So once I've opened the "Text Field Properties" box, hovered over to "Actions", would the select action be "Run a JavaScript"? If so, do you mind assisting me with the wording of the formulas I am attempting to create. I would like the following formulas to be created:
Computer Purchase Program Cost
A. *user inputted quantity*
B. A. times .20
C. A. minus B.
D. *user inputted quantity*
E. C. divided by D.
Copy link to clipboard
Copied
If you look back in the posts you'll a link to an article on writing calculations. You'll find your answers there.
https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
No, it's not under Actions. It's under the Calculate tab.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
THANK YOU!!! I keep seeing people refer to the calculate tab and I didn't have it. Having Creative Cloud, I know I have the most current version. I also didn't think I needed to write a macro for something so simple. So THANK YOU! This solved my problem!! Good to go! *big smiles*
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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!

