Fix JavaScript Variables Showing as Plain Text in Adobe Acrobat PDF Emails
Question details
The user needs to fix an issue in dynamic PDF forms where JavaScript variables render as literal text strings instead of evaluating their stored values in email outputs.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Auto-generating emails using JavaScript within an interactive dynamic PDF form.
- Observed behavior
- Variables such as client names or email addresses appear as their literal variable names in the generated email body rather than displaying the actual dynamic input values.
Ensure you have access to the Adobe Acrobat Prepare Form tool and can edit the custom JavaScript actions assigned to your PDF form buttons.
Use Proper String Concatenation for Variables
Fix the issue by ensuring variables are not enclosed within literal string quotes and are instead joined using the plus (+) operator.
JavaScript treats any text enclosed within double or single quotes as a literal string. If a variable name is placed inside these quotes, the script will output the variable's name rather than its evaluated value.
To resolve this, you must separate your plain text strings from your variables and use the concatenation operator (+) to link them together.
Open your PDF document in Adobe Acrobat, navigate to the 'Prepare Form' tool, right-click the button triggering the email, and select 'Properties'.
Go to the 'Actions' tab, select your 'Run a JavaScript' action, and click 'Edit' to view your code.
Locate the string defining the email body. Change the syntax from a literal inclusion like `var body = "Hello cYourName";` to properly concatenated code like `var body = "Hello " + cYourName;`.
Click 'OK' to save the script, close the properties window, and test the form button to ensure the generated email displays the correct dynamic value.

Manage and Fill Interactive PDF Forms Easily with WPS Office
While advanced JavaScript debugging requires specific script editors, WPS Office provides a robust, user-friendly PDF tool for viewing, filling, and managing interactive PDF forms without the hassle of complex scripting.
- 1. Open WPS PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Fill the Form: Click directly on the highlighted text fields, checkboxes, or dropdowns to input your information seamlessly.
- 3. Save or Share: Once filled, click 'Menu' and select 'Save As' to keep a copy, or use the 'Share' feature to email the completed document directly to clients.

Frequently Asked Questions
Why does JavaScript output my variable name instead of the value?
This happens when the variable name is placed inside quotation marks. In JavaScript, quotes define a literal string, so the engine ignores the variable and prints exactly what is typed.
Can I use template literals (backticks) to format strings in PDF JavaScript?
Most PDF JavaScript engines are based on older ECMAScript standards and may not fully support modern template literals (e.g., `${variable}`). It is safest to use the traditional plus (+) operator for string concatenation.
How do I add line breaks in a concatenated JavaScript email body?
To add a line break in a text string formatted for an email body via a mailto link, use the encoded newline character `%0D%0A` concatenated with your plain text strings and variables.




