PDF Editing Issues

Fix Syntax and Quote Errors in Adobe Acrobat JavaScript Calculations

Algirdas JasaitisAlgirdas Jasaitis Nov 24, 2026 868 views

Question details

The user is encountering syntax or illegal character errors when executing custom JavaScript to calculate, sum, and divide checkbox values in a PDF form.

How to Fix Syntax and Quote Errors in Adobe Acrobat JavaScripts
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Adding custom JavaScript calculations to a PDF form to perform math operations based on multiple field values.
Observed behavior
The JavaScript fails to execute, returning an 'illegal character' or 'syntax error' message instead of the calculated result.
Before you start

Ensure you have access to the PDF form's editing mode and can open the JavaScript editor for the specific calculation field.

Solution 1Recommended

Replace Smart Quotes and Balance Parentheses

The most common cause of these errors is pasting code from a word processor that uses formatted curly quotes instead of standard straight quotes.

When you copy and paste JavaScript code from Microsoft Word or rich-text web pages, standard straight quotes (") are often automatically converted into typographic smart quotes (“ ”). The Adobe Acrobat JavaScript engine does not recognize these formatted quotes, resulting in an 'illegal character' error.

Additionally, complex mathematical formulas involving addition and division require perfectly balanced parentheses to ensure the order of operations is calculated correctly.

1
Open form editing mode

Open your PDF document in Adobe Acrobat and select the Prepare Form tool from the right-hand pane.

2
Access field properties

Right-click the specific text field that contains your calculation error and select Properties from the context menu.

3
Edit the calculation script

Navigate to the Calculate tab, select 'Custom calculation script', and click the Edit button.

4
Fix curly quotes

Carefully scan your script (especially the getField functions) and manually delete any curly quotes (“ ”), replacing them with standard straight quotes (" ") using your keyboard.

5
Check parentheses

Review the mathematical expression at the end of your script (e.g., event.value = (v1 + v2 + v3) / 4;) to ensure every opening parenthesis has a matching closing parenthesis.

6
Save and test

Click OK to save your updated script, close the properties dialog, and test your form checkboxes to verify the calculation works without syntax errors.

Replace Smart Quotes and Balance Parentheses
Best Practice: Always draft and edit your PDF JavaScript code in a plain text editor like Notepad or VS Code before pasting it into Adobe Acrobat. This prevents automatic formatting of quotes and characters.
Powerful PDF Solution

Manage and Fill PDF Forms Easily with WPS Office

Need a simpler way to handle interactive PDF documents and forms? WPS Office offers a comprehensive, lightweight PDF editor that allows you to view, fill, and manage PDF files seamlessly across all your devices.

  1. 1. Download WPS Office: Download and install the free WPS Office suite from the official website.
  2. 2. Open your PDF: Launch the WPS PDF tool and open your interactive PDF form.
  3. 3. Interact with forms: Use the built-in form filling features to easily check boxes, input text, and manage your document data.
Easily fill out and manage interactive PDF forms without scripting hassleEdit PDF text, images, and pages directly within the applicationFully compatible with standard Adobe PDF formatsLightweight architecture ensures it runs smoothly on older and newer devices alike
microsoft office alternative - wps office

Frequently Asked Questions

Why do smart quotes cause errors in Adobe Acrobat JavaScript?

JavaScript syntax strictly requires standard straight ASCII quotes (" or ') to identify strings. Typographic smart quotes (“ ”) are interpreted as unrecognized special characters by the compiler, leading directly to 'illegal character' syntax errors.

How do I test my PDF JavaScript calculation without closing the editor?

You can use the JavaScript Debugger in Adobe Acrobat by pressing Ctrl+J (Windows) or Cmd+J (Mac). This allows you to run and test snippets of code in the console to pinpoint exactly which line contains the syntax error.

Will my PDF form calculations work on mobile devices?

Custom JavaScript calculations in PDF forms may not be fully supported by default mobile PDF viewers or web browsers. It is recommended that users open the interactive form in dedicated PDF software on a desktop for full script compatibility.