PDF Editing Issues

Create PDF Form Fields from Dropdowns or Multiline Text in Adobe Acrobat

Natalie TaylorNatalie Taylor Nov 25, 2026 868 views

Question details

Create PDF form fields from multiline text or display a field associated with a dropdown selection without creating duplicates.

Create PDF Form Fields from Dropdowns or Multiline Text in Adobe Acrobat
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
A form author wants to generate fields from lines of text or show a field corresponding to a selected dropdown value.
Observed behavior
Each text line should produce at most one named field, or only the field matching the selected dropdown value should be visible.
Before you start

Open the PDF in Adobe Acrobat Pro and choose All tools > Prepare a form. Confirm the exact names of the source and target fields, and make sure the page has enough space for any fields you create.

Solution 1Recommended

Create fields from multiline text with a button action

Use a button to generate fields on demand and check existing names before adding them.

This example creates text fields on the first page, using one nonblank line per field name. It replaces non-word characters with underscores, so different lines that normalize to the same name share a field.

1
Name the source field

In All tools > Prepare a form, open the multiline text field's Properties and name it multilinetext. On the Options tab, enable Multi-line.

2
Add a button action

Add a button in Prepare a form, open its Properties, and select Actions. Choose Mouse Up as the trigger, select Run a JavaScript, and click Add.

3
Enter the script

Paste this script into the JavaScript editor and click OK: var source = this.getField("multilinetext"); var lines = source.valueAsString.split(/\r\n|\r|\n/); var row = 0; for (var i = 0; i < lines.length; i++) { var line = lines[i].replace(/^\s+|\s+$/g, ""); if (!line) continue; var name = "FieldFor_" + line.replace(/[^\w]/g, "_"); var field = this.getField(name); if (!field) { var top = 530 - row * 30; field = this.addField(name, "text", 0, [149, top, 248, top - 24]); row++; } if (field) field.value = line; }

4
Test the button

Close the Properties dialog, enter a few lines in multilinetext, and click the button. Click it again to verify that existing field names are reused rather than added again.

Create fields from multiline text with a button action
Adjust the layout: The coordinates are examples in PDF points on page 0, the first page. Adjust them and limit the number of lines to fit the page. Existing fields are not repositioned, and fields from removed lines are not deleted.
Free Microsoft Office alternative

Work with PDF documents and Office files in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move between documents and PDF work. Acrobat-specific form JavaScript still requires a compatible PDF form editor.

Open and work with PDF documents alongside Office filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for a smoother transition from Microsoft OfficeFree and lightweight for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Where should I put the script that creates fields from text?

In Acrobat Pro, add a button under All tools > Prepare a form. Open its Properties > Actions, choose Mouse Up and Run a JavaScript, and add the script there so it runs on demand rather than during every calculation.

How does the script avoid creating duplicate fields?

It calls this.getField(name) before this.addField. If a field with that name already exists, the script reuses it. Lines that normalize to the same name also share a field.

Can I show only the field for the selected dropdown option?

Yes. Create the target fields in Prepare a form, then add a custom script under the dropdown's Properties > Validate tab. Map each export value to a field name and set the matching field to display.visible and the others to display.hidden.

Why do my generated fields overlap or appear off the page?

The addField rectangle uses page coordinates in PDF points. Adjust the left, top, right, and bottom values in the button script, and ensure the page has enough room for the number of lines.