Other PDF Issues

Fix JavaScript Variables Showing as Plain Text in Adobe Acrobat PDF Emails

Ayan MasoodAyan Masood Nov 24, 2026 869 views

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.

Fix JavaScript Variables Displaying as Plain Text in Adobe Acrobat Emails
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.
Before you start

Ensure you have access to the Adobe Acrobat Prepare Form tool and can edit the custom JavaScript actions assigned to your PDF form buttons.

Solution 1Recommended

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.

1
Open the JavaScript Editor

Open your PDF document in Adobe Acrobat, navigate to the 'Prepare Form' tool, right-click the button triggering the email, and select 'Properties'.

2
Locate the Email Script

Go to the 'Actions' tab, select your 'Run a JavaScript' action, and click 'Edit' to view your code.

3
Fix the Variable Syntax

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;`.

4
Save and Test

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.

Use Proper String Concatenation for Variables
Spacing Matters: Don't forget to include spaces inside your literal string quotes before or after the variable (e.g., `"This is " + variable + " text."` ) so the final output doesn't run the words together.

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. 1. Open WPS PDF: Launch WPS Office and open your interactive PDF form document.
  2. 2. Fill the Form: Click directly on the highlighted text fields, checkboxes, or dropdowns to input your information seamlessly.
  3. 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.
Seamlessly fill out interactive PDF forms without scripting errorsHighly compatible with standard PDF formats and interactive form fieldsLightweight application that loads heavy PDF documents quickly
microsoft office alternative - wps office

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.