How to Add Multiple Lines to an Acrobat PDF Email Button
Question details
The user wants to format the body of an email triggered by a PDF button to include multiple lines using JavaScript.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form with an email submission button that populates a multi-line message body.
- Observed behavior
- The user needs the correct JavaScript syntax to insert line breaks within the cMsg string for the email body.
Ensure your PDF editor supports JavaScript for interactive forms and that you have the email submit button's script properties open.
Use the Newline Escape Sequence in JavaScript
The standard way to create line breaks in a JavaScript string for PDF email buttons is by using the \n escape sequence.
When configuring a PDF email button using JavaScript, the email body is defined by the cMsg parameter. To format this message with multiple lines, you must use the standard JavaScript newline character (\n).
Open your PDF form in edit mode, right-click the Email button, and select 'Properties'.
Go to the 'Actions' tab, select 'Run a JavaScript' from the Select Action dropdown menu, and click the 'Add' or 'Edit' button.
Locate your app.mailMsg or this.mailDoc function script. Within the cMsg parameter string, insert \n wherever you want a line break. For example: cMsg: "First line\nSecond line\nThird line".
Click 'OK' to save the script, close the properties window, and click the button in viewing mode to verify the email draft formats correctly.

Edit and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to easily view, fill, and manage interactive PDF forms alongside your daily office tasks.
- 1. Download the Software: Download and install WPS Office on your desktop device.
- 2. Open Your PDF: Launch WPS Office and open your interactive PDF form using the built-in WPS PDF tool.
- 3. Fill the Form: Use the interactive elements to fill out text fields, check boxes, and click submission buttons.
- 4. Save or Submit: Save your filled form locally or submit it directly through the configured interactive buttons.

Frequently Asked Questions
Why are my line breaks not appearing in the final email?
This often happens if the user's default email client handles plain text emails differently or strips line breaks for styling purposes. Ensure your JavaScript syntax uses \n correctly, and test across different email clients like Outlook or Thunderbird.
Can I use HTML tags like <br> instead of \n in the cMsg string?
No, the cMsg parameter in standard PDF JavaScript for mailDoc or mailMsg generates plain text emails. HTML tags will be displayed as raw text, so you must use \n for line breaks.
How do I add a variable to a new line in the email message?
You can concatenate strings and variables using the + operator. For example: cMsg: "Here is the data:\n" + myVariable + "\nEnd of message."
Does this JavaScript email button work on mobile PDF viewers?
JavaScript execution, including email submission buttons, is often limited or unsupported on mobile PDF viewers. It is highly recommended that users open interactive PDF forms on desktop PDF editors for full functionality.




