PDF Editing Issues

How to Add Multiple Lines to an Acrobat PDF Email Button

Ayan MasoodAyan Masood Nov 10, 2026 869 views

Question details

The user wants to format the body of an email triggered by a PDF button to include multiple lines using JavaScript.

How to Add Multiple Lines to a PDF Email Button 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.
Before you start

Ensure your PDF editor supports JavaScript for interactive forms and that you have the email submit button's script properties open.

Solution 1Recommended

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).

1
Open Button Properties

Open your PDF form in edit mode, right-click the Email button, and select 'Properties'.

2
Navigate to the JavaScript Action

Go to the 'Actions' tab, select 'Run a JavaScript' from the Select Action dropdown menu, and click the 'Add' or 'Edit' button.

3
Insert the Newline Character

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".

4
Save and Test

Click 'OK' to save the script, close the properties window, and click the button in viewing mode to verify the email draft formats correctly.

Use the Newline Escape Sequence in JavaScript
Testing the Script: The appearance of line breaks can depend on the user's default email client (e.g., Outlook, Mail app). Always test the button on your target platform to ensure compatibility.
Efficient PDF Form Editing

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. 1. Download the Software: Download and install WPS Office on your desktop device.
  2. 2. Open Your PDF: Launch WPS Office and open your interactive PDF form using the built-in WPS PDF tool.
  3. 3. Fill the Form: Use the interactive elements to fill out text fields, check boxes, and click submission buttons.
  4. 4. Save or Submit: Save your filled form locally or submit it directly through the configured interactive buttons.
Easily fill and manage interactive PDF formsCompatible with standard PDF form fields and elementsLightweight, fast, and completely free to downloadSeamlessly convert between PDF, Word, Excel, and PowerPoint
microsoft office alternative - wps office

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.