PDF Editing Issues

Populate an Acrobat Dropdown List from Excel Using JavaScript

Tauseeq MagsiTauseeq Magsi Nov 19, 2026 868 views

Question details

Populate an Acrobat PDF dropdown with name-and-value pairs from Excel without entering each item in the form editor or clicking a button.

Product
Adobe Acrobat and Microsoft Excel
Device & OS
not provided
Scenario
The user has a name-and-value list in Excel and wants to use it in a PDF form, potentially with document-level or calculation JavaScript.
Observed behavior
The desired dropdown should load its options automatically and may populate related fields when a value is selected.
Before you start

In Excel, arrange the dropdown labels and export values in the first two columns, with a header row, and save the sheet as a CSV file. In Acrobat, create a dropdown field and note its exact field name; the example below uses Dropdown1.

Solution 1Recommended

Embed the Excel list in an Acrobat document script

Use this approach to load dropdown options when the PDF opens, without a button or direct access to the spreadsheet.

Acrobat uses JavaScript, not Java. The example embeds a snapshot of the Excel data in the PDF; it does not read the spreadsheet live. Converting the CSV to a JavaScript array requires Python for the example below.

1
Convert the CSV to an array

Save the Excel sheet as names.csv. Create a file named make_dropdown.py containing the following code, then run `python make_dropdown.py > data.txt` from the folder containing both files: import csv, json with open('names.csv', encoding='utf-8-sig', newline='') as f: rows = [row[:2] for row in list(csv.reader(f))[1:] if len(row) >= 2] print('var cells = ' + json.dumps(rows, ensure_ascii=True) + ';')

2
Add a document-level script

In Acrobat, open the PDF and find Document JavaScripts under the JavaScript tools; the menu location varies by version. Create a script, paste the contents of data.txt into it, and add this code below the array: var dropdown = this.getField('Dropdown1'); if (dropdown) dropdown.setItems(cells); Replace Dropdown1 with your actual dropdown field name. Each pair in cells supplies a displayed label followed by its export value.

3
Save and test the PDF

Save the PDF, close it, and reopen it in Acrobat. Open the dropdown and check that the labels appear and that selecting an item uses the intended export value.

4
Refresh changed source data

When the Excel list changes, save a new names.csv, rerun the Python command, and replace the array in the document-level script with the new contents of data.txt. Save, close, and reopen the PDF to reload the options.

External file access: A calculation script is not a reliable way to load a spreadsheet dynamically. Acrobat security restrictions can prevent direct access to external files, so the embedded-array method requires an update when the source data changes.
Free Microsoft Office alternative

Work with Excel Lists and PDFs in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with spreadsheets and PDFs. Open compatible Office files to manage your source lists and migrate everyday document workflows easily. It does not replace the Acrobat-specific JavaScript workflow described above.

Organize dropdown source lists in WPS SpreadsheetCompatible with Microsoft Excel XLSX and XLS filesView PDFs alongside your spreadsheet filesFamiliar interface for moving from Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Can Acrobat read the Excel file directly every time the PDF opens?

Direct external file access can be blocked by Acrobat security restrictions. The embedded-array method avoids that access but requires you to regenerate and replace the array when the Excel data changes.

Do I need a button to populate the dropdown?

No. Add a document-level JavaScript that calls setItems on the dropdown field, then save and reopen the PDF so the script can load the options.

What is the difference between a dropdown label and an export value?

The label is what the user sees in the dropdown; the export value is the associated value used by the form. In the example array, the first column is the label and the second is the export value.

Why does the related field remain blank after I select an item?

In Prepare a Form, check that the target field name matches the name in this.getField and that the dropdown's export values match the second column of cells. Also check that the document-level array script is present.