PDF Editing Issues

Combine Values from Spawned PDF Pages into a Multiline Text Field

Steven ParkerSteven Parker Nov 10, 2026 868 views

Question details

The user needs to extract and combine Street_No and Street field values from spawned PDF pages into a single multiline text field, properly formatted with spaces and line breaks.

Combine Values from Spawned PDF Pages into a Multiline Text Field
Product
PDF Forms
Device & OS
not provided
Scenario
Creating or editing interactive PDF forms that use JavaScript to dynamically gather and summarize data from spawned template pages.
Observed behavior
The current calculation script joins street names without spaces or line breaks, and contains improper loop initialization syntax.
Before you start

Ensure that your target PDF form field has the 'Multi-line' property enabled, and verify that you have access to edit the custom JavaScript calculation scripts within the form.

Solution 1Recommended

Use Correct JavaScript Loop Syntax and Line Breaks

Apply a numeric index for your loop and use the carriage return character to format the concatenated values with spaces and line breaks.

To properly format the combined data, you must ensure your JavaScript loop is initialized correctly as a number rather than an empty string. Additionally, explicitly adding a space character and a carriage return will correctly format the output into multiple lines.

1
Fix the loop syntax

Open the custom calculation script for your summary field. Locate the loop initialization and change it from an empty string to a zero: for(var i=0; i<this.numFields; i++).

2
Define the line break variable

Before or within your loop, define a variable for the carriage return by typing: var newLine = "\r";

3
Concatenate with spaces

Update your field combination logic to insert a space between the street number and name, and append the line break at the end. For example: nStreet += streetNumber + " " + streetName + newLine;

4
Assign the value

Ensure the concatenated string is correctly assigned to the value of your destination multiline text field.

Use Correct JavaScript Loop Syntax and Line Breaks
Enable Multi-line Property: For the line breaks to appear visually, right-click the destination text field, open Properties, navigate to the Options tab, and check the 'Multi-line' box.
WPS PDF Form Editor

Create and Edit PDF Forms Easily with WPS Office

WPS Office features a robust PDF editor that simplifies the creation and management of interactive form fields. You can easily add multiline text boxes, configure field properties, and manage form calculations without complex coding.

  1. 1. Open your PDF file: Launch WPS Office and open your existing PDF document or create a new one.
  2. 2. Access form tools: Navigate to the 'Form' tab located in the top ribbon menu to view all interactive elements.
  3. 3. Insert a text field: Click on 'Text Field' and drag your cursor on the document to draw the input box.
  4. 4. Enable multiline input: Double-click the inserted text field to open Properties, go to the Options tab, and check the 'Multi-line' setting.
  5. 5. Save and deploy: Save your PDF document. The form is now ready for users to enter formatted, multiline data.
Seamlessly insert text fields, checkboxes, and interactive buttons.Fully compatible with standard PDF forms and Adobe Acrobat formatting.Lightweight software with an intuitive, user-friendly interface for effortless editing.Built-in settings for multi-line formatting and advanced field properties.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF text field not showing multiple lines despite adding line breaks?

If your text appears on a single continuous line, you need to enable the 'Multi-line' property for that field. Right-click the text field, go to Properties, select the Options tab, and check the 'Multi-line' box.

What is the correct JavaScript character for a line break in PDF forms?

In PDF form JavaScript, you should use the carriage return character `\r` or the newline character `\n` within your string concatenation to insert a line break into a multiline text field.

How do I loop through form fields correctly in PDF JavaScript?

Ensure you initialize your loop variable as a number (e.g., `var i = 0`) rather than an empty string (`var i = ""`). A standard `for` loop written as `for(var i = 0; i < this.numFields; i++)` will correctly iterate through all fields in the document.