PDF Editing Issues

Multiply an Acrobat Form Field and Return Four Characters

Huda QurayshiHuda Qurayshi Nov 19, 2026 869 views

Question details

The user wants to multiply a PDF form field by 150 and display the first four characters of the result in another field.

Multiply an Acrobat Form Field and Return Four Characters
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form needs a destination field that calculates a value from a source field.
Observed behavior
The destination field should show the first four characters of the calculated result, or remain blank if the result has fewer than four characters.
Before you start

Open the PDF in Acrobat and confirm that it contains a source text field and a destination text field. Check the source field's exact name in its properties, and make sure Acrobat JavaScript is enabled in Preferences.

Solution 1Recommended

Add a custom calculation script to the destination field

Use this method to calculate the result automatically in an Acrobat PDF form.

1
Open the form editor

In Acrobat, open the PDF and select Prepare a Form from the tools menu.

2
Open destination field properties

Double-click the destination text field, such as Text2, and select the Calculate tab.

3
Enter the calculation script

Select Custom calculation script, click Edit, and enter: var num = Number(this.getField("Text1.0.1").valueAsString) * 150; var str = num.toString().slice(0, 4); if (str.length == 4) event.value = str; else event.value = ""; Replace Text1.0.1 with the exact name of your source field.

4
Save and test the form

Confirm the script, close the field properties, and save the PDF. Enter 10 in the source field to check that the destination displays 1500; entering 5 should leave it blank.

5
Repeat for other fields

To calculate from another source field, open the corresponding destination field's Calculate tab, copy the script, and update the source field name.

Add a custom calculation script to the destination field
Characters versus digits: The script takes the first four characters of the result's text representation. A minus sign or decimal point counts as a character, so use positive whole-number results if you need four digits.
Free Microsoft Office alternative

Calculate form values in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface and support for common Office formats, making it easy to move existing files. Use WPS Spreadsheets for a worksheet-based version of this calculation; it does not add an Acrobat calculation script to a PDF form.

Calculate values from cells in WPS SpreadsheetsOpen and save Microsoft Excel XLSX filesWork with Microsoft Word and PowerPoint formatsUse a familiar interface for an easier transition from Microsoft Office
QA img-9

Frequently Asked Questions

Where do I find the custom calculation script box in Acrobat?

Open Prepare a Form, double-click the destination field, and select Calculate. Choose Custom calculation script and click Edit.

Why is the destination field blank when the result is 750?

The script displays a value only when the sliced result contains four characters. Since 750 has only three, the destination field is cleared.

How do I use the script with a different source field?

In the destination field's custom calculation script, replace Text1.0.1 inside this.getField() with the exact name shown in the source field's properties.

Does the script always return four numeric digits?

No. It returns the first four characters of the result's text representation. For negative or decimal results, a minus sign or decimal point can be included.