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

WorkSheet Calculations

pdfer
Registered: Dec 23 2010
Posts: 28
Answered

My issue in a nut shell. I have built a PDF Worksheet used to calculate materials to build a chain link fence (line and terminal posts, fence fabric, concrete, gates, labor, etc,. It is made up of many Drop Down fields and Text fields which calculates. All works fine except these three fields. Which I'd like to use to calculate the number of line posts and line post spacing. This one sounds simple, right? Nope. I cannot seem to get the right formula.
 
I'll explain a bit further. I have 3 fields. Field #1 named Footage. Field #2 named LinePosts. Field #3 named Spacing. So, I enter the footage then I want to have the two other fields to make their individual calculations. LinePosts should calculate then show the number of posts, then the Spacing field would calculate then show the post spacing.
 
Now, typically when building a fence the line post spacing cannot be greater than 10' apart (keep this in mind).
 
Example: For 200' (Footage) the line post spacing would be 10' apart and would take 19 posts giving you 20 spaces for that line (20x10=200'). But, if the Footage entered is 72' then the line post spacing would be 9' apart and would take 7 line posts giving you 8 spaces (8 x 9=72'). But, if the Footage entered is 38' then the line post spacing would be 9'6" and would take 4 spaces (4 x 9'6"=38'). And so on.
 
I'm not a Acrobat novice but definitely not an expert either. Far from it. And, I always seem to figure it out, but not when it comes to these three fields. I have tried Simplified field notation and/or Custom calculation script and just can't get it right. I'm thinking perhaps Javascript.
 
Perhaps you guys can help me with this issue? I'm on a Mac and use Acrobat Pro 9.
 
Thank you for taking the time to read this post.

Jackson C.

My Product Information:
Acrobat Pro 9.0, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
Because your calculation will require division and the use of the Math property ceil, you can not use the simplified field notation.

You will find the spacing by dividing the footage by the footage divided by 10 and rounding up to the next whole number.

Once you find the spacing then the number of post becomes the footage divided by the spacing less 1.

The calculation for the spacing:

event.value = '';
var Footage = this.getField('Footage').value;
if(Footage >0)
event.value = Footage / Math.ceil(Footage/10);

The calculation for the number of post:

event.value = '';
var Footage = this.getField('Footage').value;
if(Footage >0)
event.value = (Footage / (Footage / Math.ceil(Footage/10)) ) - 1;

The results for the spacing is in feet.

George Kaiser

pdfer
Registered: Dec 23 2010
Posts: 28
Thank you George. It's amazing. I've been working on this for about a year (off and on) and could only come close. You got it within a few minutes. Thank you again.

But, I do have another question. Regarding doc protection/expire. The document is mostly made up of Javascript. So, if a person disables Javascript they will not be able to use my doc. In a sense - Document Protection! But the point is, I want the viewer to use my doc. To use my doc the proper way the viewer MUST Enable Javascript. So in this case, I have a Javascript to Expire on PageOpen. Great and it works to whatever date I select. But, as you know, if they set back their computer's calendar it defeats the expiration code.

So, my question is: Would you know how to also add in a Javascript that would shut down the doc if the date was different than the Date written in the Javascript. Let's say, close document if date is not (for example) January 7, 2011. Would that be a different PageOpen Javascript? Would possibly know of any additional protection measures?

If this can be done. Wouldn't it be a stronger and more secure form of protection? Then Password the whole thing. Making it essentially iron clad if my document fell into the wrong hands.

Jackson C.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
This approach in not iron clad at all. It can be very easily overcome by disabling JavaScript.
You should not use JavaScript as a way of protecting your file.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com