PDF Editing Issues

Show PDF Layers with a Drop-Down List in Adobe Acrobat

Jason MillerJason Miller Nov 24, 2026 868 views

Question details

Create a PDF language drop-down that shows the matching layer and restores the saved selection when the document reopens.

Show and Hide PDF Layers with a Drop-Down List in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form contains separate English and Spanish optional content groups, and the reader selects a language from a drop-down list.
Observed behavior
The selected language layer should be visible, the other language layer should be hidden, and the saved choice should be restored on reopening.
Before you start

Use a PDF that already contains English and Spanish layers, and check their exact names in Acrobat’s Layers panel. You also need a form-editing version of Acrobat and a PDF viewer that supports Acrobat JavaScript and optional content groups.

Solution 1Recommended

Switch and restore language layers with Acrobat JavaScript

Use the drop-down’s saved form value to control the two layers and restore the choice when the PDF opens.

This example assumes the layer names and drop-down export values are exactly English and Spanish. Change the names in the script if your PDF uses different ones.

The selection persists only if the reader saves the modified PDF. JavaScript or layer controls may not work in browser viewers or other PDF apps.

1
Create the language field

In Acrobat, open All tools > Prepare a form and add a drop-down named Language. In the field’s Options properties, add English and Spanish, using the same words as their export values. Enable the option to commit the selected value immediately if it is available.

2
Add the document script

Open All tools > Use JavaScript > Document JavaScripts, create a script, and add: function applyLanguage(language) { var groups = this.getOCGs(); if (!groups) return; for (var i = 0; i < groups.length; i++) { if (groups[i].name === 'English') groups[i].state = (language === 'English'); if (groups[i].name === 'Spanish') groups[i].state = (language === 'Spanish'); } } var languageField = this.getField('Language'); if (languageField) applyLanguage(languageField.value);

3
Connect the drop-down

In Prepare a form, open the Language field’s Properties, select Validate, and choose Run custom validation script. Enter: applyLanguage(event.value); This applies the layer visibility when the selected value is committed.

4
Test the layer display

Exit form editing and choose English, then Spanish, from the Language drop-down. Check that the matching layer appears and the other disappears. If the display does not update as expected, test the PDF in Acrobat with JavaScript enabled.

5
Save and reopen

Choose a language, save the PDF with File > Save, close it, and reopen it in Acrobat. The document script reads the saved Language field value and applies the corresponding layer state.

Switch and restore language layers with Acrobat JavaScript
Saving is required: The script does not save the file automatically. The reader must be allowed to save form changes and must save after choosing a language.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and migrating Office files. It does not replace Acrobat JavaScript for the layer-switching workflow described above.

Open and review PDFs alongside your Office documentsCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for an easier transition from Microsoft OfficeFree tools in a lightweight office suite
QA img-9

Frequently Asked Questions

Why does the PDF reopen with the wrong language?

Make sure the reader saved the PDF after changing the Language field. Also check that the document-level script runs on opening and that its layer names match those in the Layers panel.

Can I use different layer or drop-down names?

Yes. Update the names in the document script to match the Layers panel and the drop-down’s export values. If you rename the field, also change Language in the getField call.

Will the drop-down work in a browser PDF viewer?

Not necessarily. Browser viewers may not support Acrobat JavaScript or optional content groups fully. Test the saved form in Acrobat or a viewer that supports both.

Does selecting a language automatically save it?

No. The reader must save the PDF after selecting a language, and the viewer and document permissions must allow form changes to be saved.