How to Calculate 10 Percent GST in PDF Forms Using Acrobat JavaScript
Question details
The user needs to set up an automated calculation in an interactive PDF form to compute a 10% Goods and Services Tax (GST) based on the sum of two other fields.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Creating or configuring an interactive PDF form that requires automated tax calculations based on user input for sales and freight.
- Observed behavior
- The target GST field needs to dynamically display exactly 10% of the combined numeric values entered into the Sales Amount and Freight fields.
Verify the exact names of your input form fields (e.g., 'Sales Amount' and 'Freight') in your PDF editor before writing your calculation script, as JavaScript is strictly case-sensitive.
Use a Custom JavaScript Calculation for the GST Field
Add a custom JavaScript code snippet to the Calculate action of your GST form field to automatically compute 10% of the combined totals.
Interactive PDF forms rely on JavaScript to perform dynamic mathematical calculations. By utilizing a custom calculation script, you can extract numeric values from specific form fields, perform addition, and apply the required 10% multiplication factor.
Open your PDF in Acrobat's form editing mode, right-click the GST text field where the result should appear, and select 'Properties'.
In the Properties dialog box, click on the 'Calculate' tab to view the available calculation methods.
Select the 'Custom calculation script' radio button and click the 'Edit' button. Paste the following JavaScript code: var salesAmount = Number(this.getField("Sales Amount").valueAsString); var freight = Number(this.getField("Freight").valueAsString); event.value = (salesAmount + freight) * 0.1;
Click 'OK' to close the JavaScript editor, then close the Properties dialog. Exit form editing mode and type numeric values into the Sales Amount and Freight fields to verify the GST field updates correctly.
Edit and Fill PDF Forms Easily with WPS Office
WPS Office features a powerful PDF editor that allows you to seamlessly view, fill, and manage interactive PDF forms without relying on heavy or expensive software.
- 1. Open WPS Office PDF: Launch WPS Office on your device and click on 'Open' to select your interactive PDF form.
- 2. Interact with Form Fields: Navigate through the document; WPS PDF will automatically highlight fillable text fields for you.
- 3. Input Data and Save: Enter your numeric values into the designated sales and freight fields, trigger the calculations, and save the completed document safely.

Frequently Asked Questions
Why is my GST calculation script returning an error or zero?
This usually happens if the field names in your script do not exactly match the field names in your PDF form properties. Double-check for typos, extra spaces, and ensure case sensitivity aligns perfectly.
Can I change the GST percentage in the custom script?
Yes, you can easily adjust the multiplier in the script to reflect different tax rates. For example, to calculate a 15% tax instead of 10%, change '* 0.1' to '* 0.15' in the final line of the JavaScript code.
How do I format the calculated GST to always show two decimal places?
In the GST field's properties dialog, navigate to the 'Format' tab. Select 'Number' from the Select format category dropdown menu, and configure the Decimal places setting strictly to 2.




