These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Java Calculations

Xenuite
Registered: Jun 12 2008
Posts: 4

I've been trying to make an Acrobat spreadsheet work, but it looks like I'm going to have to dive into Javascript to get it to calculate correctly. I'm going to need three calculations.

1. I want one form to display the value of another form minus 10, then divided by 2 and rounded down to the nearest integer.

2. I want the second form to display the above value plus the value of another form divided by 2 and rounded down to the nearest integer.

3. Finally, I want the third form to display a value divided by 2 and rounded down to the nearest integer.

Can anyone give me a hand?

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, you will need to learn quite a bit of JavaScript. The problem isn't doing the calculations. That part is easy. See this article for info on calculations:

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/form_calculations/

The problem is getting data from other PDFs. So where are these PDFs relative to the one that's doing the calculations? Are they already open in Acrobat? Are they in the same folder? The important thing is that they are somewhere the calculation script knows about.

The script will need to open the source PDF. Acquire the fields it needs, and then close the source PDF. In order for this to work the source PDF will need to be disclosed. This means that the form's "disclosed" property is set to true. Place the following code in a document script in all of your forms.

this.disclosed = true;

You'll find articles that cover everything you need to do for this on JavaScript Corner:

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/index.php?sort=true&search_keyword=All

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script