PDF Editing Issues

Combine PDF Form Fields Into a Numbered List With Acrobat JavaScript

Huda QurayshiHuda Qurayshi Nov 19, 2026 868 views

Question details

Combine multiple PDF text field values into one numbered, multiline summary field.

Combine PDF Form Fields Into a Numbered List With Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form contains several text fields whose nonempty values should appear in a single summary field.
Observed behavior
The desired summary displays each nonempty value on a separate line, numbered consecutively.
Before you start

Identify the exact names of the source fields and the summary field in Acrobat's Prepare a form tool. Make sure the summary field is a text field and is not included among the source fields.

Solution 1Recommended

Use a Custom Calculation Script in the Summary Field

Use this approach to automatically collect nonempty field values and number them without gaps.

1
Open the summary field properties

In Adobe Acrobat, open the PDF and select All tools > Prepare a form. Double-click the summary text field to open its Properties dialog.

2
Enable multiple lines

In the Properties dialog, open the Options tab and select Multi-line so the summary can display each entry on a separate line.

3
Add the calculation script

Open the Calculate tab, select Custom calculation script, and click Edit. Paste this script, replacing Field1, Field2, and Field3 with the exact source field names: var fields = ["Field1", "Field2", "Field3"]; var values = []; for (var i = 0; i < fields.length; i++) { var field = this.getField(fields[i]); if (field) { var v = field.valueAsString; if (v.replace(/^\s+|\s+$/g, "")) { values.push((values.length + 1) + ". " + v); } } } event.value = values.join("\n");

4
Save and test the form

Close the script editor and Properties dialog, then save the PDF. Enter values in several source fields, leaving at least one blank, and check that the summary has consecutive numbers on separate lines.

Use a Custom Calculation Script in the Summary Field
JavaScript support: The calculation requires a PDF viewer that supports Acrobat form JavaScript. If it does not run in Acrobat, check Preferences > JavaScript and make sure Acrobat JavaScript is enabled.
Free Microsoft Office alternative

Work With PDFs and Office Documents in WPS Office

WPS Office is a free, lightweight, easy-to-use alternative for working with PDFs and Office documents. Its familiar interface and format compatibility make it easy to move existing files into your workflow. Use Acrobat to create and test the JavaScript calculation described above.

Open and work with PDF documents in WPS OfficeCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface helps ease migration from Microsoft OfficeLightweight suite brings document, spreadsheet, and presentation tools together
microsoft office alternative - wps office

Frequently Asked Questions

Why are the entries joined on one line?

In the summary field's Properties > Options tab, enable Multi-line. In the custom calculation script, use values.join("\n") to put a newline between entries.

How does the script skip empty fields without leaving gaps in the numbering?

The script adds a value only when it contains non-whitespace text. It uses values.length + 1 for the next number, so skipped fields do not create gaps.

Where do I find the field names for the script?

Open All tools > Prepare a form in Acrobat and inspect the form fields. Use each source field's exact name in the script's fields array, and leave out the summary field.

Why doesn't the summary update in my PDF viewer?

The viewer must support Acrobat form JavaScript. Test the form in Acrobat and check Preferences > JavaScript to confirm that Acrobat JavaScript is enabled.