Add Line Breaks Between Names in an Acrobat Form Field
Question details
Display names from multiple Acrobat form fields on separate lines in a calculated text field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A form uses JavaScript to combine names from multiple fields into one destination field.
- Observed behavior
- The desired result is a destination field that shows each name on its own line.
Open the PDF in a version of Adobe Acrobat that supports editing forms, and identify the source field names and destination text field. You will need to edit the destination field's properties and calculation script.
Use a JavaScript newline in a multiline Acrobat text field
Use this method when a calculated form field combines names and should display each one on a separate line.
For example, a custom calculation script can use event.value = this.getField("Name1").valueAsString + "\n" + this.getField("Name2").valueAsString;. Replace Name1 and Name2 with the actual source field names.
In Adobe Acrobat, open the PDF and select Prepare a Form from the tools menu.
Open the destination text field's Properties, select the Options tab, and check Multi-line. Make the field tall enough to show the expected number of names.
In the field's Properties, open the Calculate tab, select Custom calculation script, and click Edit. Replace the space separator between names with "\n", or use ", \n" if you also want a comma.
Close the field properties, use Preview in Prepare a Form, and enter names in the source fields. Confirm that the destination field displays each name on a separate line.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for working with documents and PDFs. Its format support makes it easy to move existing Office files; however, it does not fix an Acrobat calculation script or guarantee support for Acrobat form JavaScript.

Frequently Asked Questions
What JavaScript character puts the next name on a new line?
Use the newline escape sequence "\n" between the field values. Use ", \n" instead if you want a comma before the line break.
Why are the names still on one line?
In Prepare a Form, open the destination field's Properties and check Multi-line on the Options tab. Also check that the calculation script uses "\n" rather than a space.
Where do I edit the form calculation script?
In Acrobat, select Prepare a Form, open the destination field's Properties, and go to Calculate. Select Custom calculation script and click Edit.
How do I show more than two names?
Add each source field to the calculation with "\n" between values, using its actual field name. Enlarge the destination field so the additional lines are visible.




