PDF Editing Issues

How to Calculate 10 Percent GST in PDF Forms Using Acrobat JavaScript

Kushani NimanthikaKushani Nimanthika Nov 3, 2026 869 views

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.

How to Calculate 10 Percent GST in PDF Forms Using Acrobat JavaScript
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.
Before you start

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.

Solution 1Recommended

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.

1
Access Field Properties

Open your PDF in Acrobat's form editing mode, right-click the GST text field where the result should appear, and select 'Properties'.

2
Navigate to Calculation Settings

In the Properties dialog box, click on the 'Calculate' tab to view the available calculation methods.

3
Insert Custom Script

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;

4
Save and Test

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.

Field Name Matching: The field names inside the getField("") function in the JavaScript must exactly match your actual PDF form fields, including all spaces and capitalization.

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. 1. Open WPS Office PDF: Launch WPS Office on your device and click on 'Open' to select your interactive PDF form.
  2. 2. Interact with Form Fields: Navigate through the document; WPS PDF will automatically highlight fillable text fields for you.
  3. 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.
Easily fill out, edit, and save interactive PDF formsHighly compatible with standard Adobe PDF formats and structuresAdd custom text, electronic signatures, and annotations to PDFsLightweight desktop application with an intuitive interface
microsoft office alternative - wps office

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.