Copy link to clipboard
Copied
Hi,
I'd like to have the attached PDF calculate the required materials needed based on the square footage of a space.
In the example provided,
Area Totals (ft) shown are 11ft length x 12ft width.
The Total Square Feet (length x width) calculation is 125.33.
Total Square Feet's calculation is using 10.666667 x 11.75 = 125.33.
What script can I use to ensure Total Square Feet is calculated using round numbers from Area Totals (ft), which are Length 11 ft and Width 12 ft in my example?
Thank you in advance.
Copy link to clipboard
Copied
In the "TotalSquareFeet" field use a custom calcuation script like this:
event.value = Math.round(Math.ceil(this.getField("AreaTotalsftlength1").value) * Math.ceil(this.getField("AreaTotalsftwidth").value) );
If you do it like this it will total in a consistent manner as shown by any square footage online calculator:
You should get this result in your PDF:
Copy link to clipboard
Copied
For those two fields, instead of using "Number" to format them, add the following custom format script in both of them:
event.value = Math.ceil(event.target.value);
Here's a copy of your original with the scripts added to it: Project Estimator
Copy link to clipboard
Copied
I agree with Asim, but I think in this case, when you're converting "feet to inches to inches" in the formula that is currently used the accurate result is : 15.833333333333334.
Since it is a project estimator is OK to make this rounding up. If it was a construction project where you are actually buying panels of wood to build a wall in a house, then yes; it is extremely important to punch in the exact measurements, so that you don't get overcharged, and so thaty you also don't run short on materials if your contractor cuts everything with the incorrect measurements.
Copy link to clipboard
Copied
Use this code:
var v1 = Number(this.getField("AreaTotalsftlength1").valueAsString);
var v2 = Number(this.getField("AreaTotalsftwidth").valueAsString);
event.value = (v1*v2).toFixed(2);
Copy link to clipboard
Copied
In the "TotalSquareFeet" field use a custom calcuation script like this:
event.value = Math.round(Math.ceil(this.getField("AreaTotalsftlength1").value) * Math.ceil(this.getField("AreaTotalsftwidth").value) );
If you do it like this it will total in a consistent manner as shown by any square footage online calculator:
You should get this result in your PDF:
Copy link to clipboard
Copied
Thank you very much for this script. It worked perfectly!
Copy link to clipboard
Copied
How can I get the Area Totals (ft) to always round up? Is there a script that will make this work?
In the attached image, the Area Totals (ft/in) are 15 ft 10 inches for Length and 12 ft 5 inches for Width.
The Area Totals (ft) are shown as 16 ft Length and 12 ft Width (however if you click it shows 15.833 Length and 12.41667 Width).
I am trying to get the Area Totals (ft) shown to display 16 ft Length and 13 ft Width so that the calculation shown for Total Square Feet will appear accurate. Total Square Feet is 208 ft. which is (16x13).
Any help would be appreciated.
Copy link to clipboard
Copied
Why would you round up so much? Shouldn't you be accurate?
Copy link to clipboard
Copied
I agree with Asim, but I think in this case, when you're converting "feet to inches to inches" in the formula that is currently used the accurate result is : 15.833333333333334.
Since it is a project estimator is OK to make this rounding up. If it was a construction project where you are actually buying panels of wood to build a wall in a house, then yes; it is extremely important to punch in the exact measurements, so that you don't get overcharged, and so thaty you also don't run short on materials if your contractor cuts everything with the incorrect measurements.
Copy link to clipboard
Copied
For those two fields, instead of using "Number" to format them, add the following custom format script in both of them:
event.value = Math.ceil(event.target.value);
Here's a copy of your original with the scripts added to it: Project Estimator
Copy link to clipboard
Copied
Thank you!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now