How to Hide Multiple PDF Layers at Once in Adobe Acrobat
Question details
The user needs to hide multiple PDF layers at once without changing each layer individually.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF contains many layers, but the user wants to leave only a required layer visible.
- Observed behavior
- Keyboard shortcuts and Ctrl+A do not select multiple items in the Acrobat Layers panel, making individual layer changes time-consuming.
Open the PDF in Adobe Acrobat Pro and check the exact name of the layer you want to keep in the Layers panel. Make sure Acrobat JavaScript is enabled in Preferences > JavaScript.
Use Acrobat JavaScript to hide all but one PDF layer
Use the JavaScript console when the Layers panel does not support selecting multiple layers for a visibility change.
This script changes the visibility of document layers, not page selection. It keeps every layer with the specified name visible and hides the other layers.
With the PDF open in Acrobat Pro, press Ctrl+J on Windows or Command+J on macOS to open the JavaScript console.
Paste this script into the console and replace Layer to keep with the exact layer name, keeping the quotation marks: var ocgs = this.getOCGs(); if (!ocgs) { console.println("No PDF layers found."); } else { var keep = "Layer to keep"; var found = false; for (var i = 0; i < ocgs.length; i++) { if (ocgs[i].name === keep) found = true; } if (!found) { console.println("Layer not found: " + keep); } else { for (var j = 0; j < ocgs.length; j++) { ocgs[j].state = (ocgs[j].name === keep); } } }
Select the entire script in the console and press Ctrl+Enter on Windows or Command+Enter on macOS. Check the Layers panel and the PDF pages to confirm the intended content remains visible.
Use File > Save As to save a copy, then reopen it to verify whether the desired layer visibility was retained.

Work with PDF and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for viewing PDFs and working with Office files. Its format compatibility makes it easy to move existing documents into your workflow; use Acrobat for the layer-visibility script described above.

Frequently Asked Questions
Can I select all layers with Ctrl+A in Acrobat?
Ctrl+A may not select multiple entries for a visibility change in the Layers panel. If it does not work, use the Acrobat JavaScript console to change layer states in one operation.
What happens if the layer name in the script is wrong?
The script prints a Layer not found message and leaves layer visibility unchanged. Check the exact name in the Layers panel and update the keep value before running it again.
Will the script hide layers on every page?
It changes the visibility of document layers returned by getOCGs, so the effect can extend across pages. It does not select or hide pages themselves.
Will the visibility changes remain after I save the PDF?
Persistence can depend on the PDF and its settings. Use File > Save As, then reopen the saved copy to check the layer visibility.
What if the JavaScript console does not open?
Check Preferences > JavaScript to make sure Acrobat JavaScript is enabled, and use Acrobat Pro to access the JavaScript console.




