# Calcululation in PDF Form

I have a form that I'd like to calculate the results in and I'm hoping someone could help me.

I want to calculate the percentage of 2 fields.

In the top right hand side of this form is Score: _____ Good   ____  Bad     _____  %
-form.pdf
LVL 4
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
There is something called PDFBox, open source library.
Commented:
Reading your question again, maybe you don't need the library interface, in which case the calc would be on the lines of

``````float universe=5;
float good =4;

float percentgood = 100/(universe/good);

System.out.println(percentgood);
``````

(but excuse me if you were not looking for code, (as it is quite straightforward)).
Project ManagerAuthor Commented:
Would I enter this info under Text Field Properties, Calculate, Custom calculation script:?

And....my fields are really named:
Good, Bad and Calc with Calc being the field where I want the formula calculated.
Project ManagerAuthor Commented:
Project ManagerAuthor Commented:
Commented:
I am not familiar with the PDFBox library, and so I cannot speak about how it interfaces with Java.
Commented:
Hi

you don't need JS

go  to your PDF. Format Good and Bad as numbers, Calc as Percentage (Right click Properties on each field)

The in Calc field go to Calculation and use the Simplified field notation and put
``````Good/Bad/100
``````
.

This will give you percentage of the two fields. You need the "/100" as stupidly Adobe PDF makes its own x100 calculation for the Percentage value

I have a sample attached.

hth
capt.
Percentage.pdf

Experts Exchange Solution brought to you by