How to Add Line Breaks Between PDF Form Field Values
Question details
The user needs to combine multiple PDF form fields into one text field using JavaScript and requires a way to insert paragraph or line breaks between the merged values.

- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Designing interactive PDF forms where multiple inputs need to be merged and displayed clearly on separate lines within a single destination text field.
- Observed behavior
- The user needs to format the combined text output with appropriate spacing so the text spans multiple lines correctly instead of running together on a single line.
Ensure you have the necessary permissions to edit the PDF form and that your destination text field is properly configured to allow multiline input.
Use the Newline Escape Sequence in JavaScript
The most direct way to add line breaks between form values is by using the \n character in your custom calculation script.
To combine different fields and format them with line breaks, you must use standard JavaScript escape characters. A single \n creates a new line, while \n\n creates a paragraph break.
Right-click the destination text field in your PDF editor, select 'Properties', and check the 'Multi-line' option under the Options tab. This ensures the field can display more than one line of text.
Navigate to the 'Calculate' tab in the text field properties and select the option to use a 'Custom calculation script'.
Enter your script using \n to insert the line breaks. For example: var output = field1 + "\n\n" + field2 + "\n" + field3; event.value = output;
Close the properties window and test the form by entering values into the source fields to verify that the destination field populates with the correct line breaks.

Create and Manage PDF Forms Seamlessly with WPS PDF
WPS Office features a powerful built-in PDF editor that allows you to easily view, manage, and fill interactive PDF forms. With native support for diverse field types and excellent formatting capabilities, it offers an intuitive experience for handling complex PDF tasks.
- 1. Open your PDF: Launch WPS Office and open the interactive PDF form you need to manage.
- 2. Access PDF tools: Navigate to the 'PDF' tab to utilize the comprehensive viewing and editing toolset.
- 3. Fill and format: Click into the interactive fields to input your data, utilizing built-in multiline support for clear formatting.
- 4. Save the document: Once your form is filled out correctly, click 'Save' or export it directly to your preferred format.

Frequently Asked Questions
Why are my line breaks not appearing in the destination PDF field?
The most common reason is that the destination text field is not set to allow multiline input. You must check the 'Multi-line' option in the text field's properties for the \n script to work.
Can I add a full paragraph break instead of just a single line break?
Yes, you can add a full paragraph break by inserting the newline escape sequence twice (\n\n) between your form field variables in the custom JavaScript code.
Does this JavaScript solution work across all standard PDF readers?
Yes, as long as the PDF viewer or application supports standard JavaScript for PDF forms, the calculated multi-line text will display correctly across different devices and readers.




