PDF Editing Issues

Hide PDF Images and Radio Button States with Acrobat JavaScript

Huma Ashraf ChHuma Ashraf Ch Nov 18, 2026 869 views

Question details

Control multiple PDF images with radio buttons and hide the images again when the document opens or the form resets.

Hide PDF Images and Control Them with Radio Buttons in Acrobat
Product
Adobe Acrobat and Acrobat Reader
Device & OS
not provided
Scenario
A PDF form uses radio buttons to display associated images.
Observed behavior
An image that was displayed remains visible after the page is refreshed or reopened, rather than returning to its hidden state.
Before you start

Open the PDF in Adobe Acrobat and identify the radio group, its export values, and the image fields you want to control. Test the finished form in Acrobat or Reader, because browser PDF viewers may not run Acrobat JavaScript.

Solution 1Recommended

Control image button fields with Acrobat JavaScript

Use button fields as image containers and explicitly reset their visibility when the document opens or the form resets.

The example uses a radio group named ImageChoice with export values A and B, and button fields named ImageA and ImageB. Replace these names and values with those in your form.

1
Create the image fields

In Acrobat, open Prepare a form and add a button field for each image. In each button's Properties, use the Options tab to choose an icon and an icon-only layout, then set the field to Hidden on the General tab.

2
Add the radio buttons

In Prepare a form, add radio buttons in a group named ImageChoice. In each button's Properties, set its export value to match the image it should show, such as A or B.

3
Reset images on open

Open Acrobat's Document JavaScripts tool and add a document-level script containing: function hideImages() { this.getField('ImageA').display = display.hidden; this.getField('ImageB').display = display.hidden; } hideImages();

4
Show the selected image

In each radio button's Properties, open Actions and add a Run a JavaScript action for Mouse Up. Use: hideImages(); var choice = this.getField('ImageChoice').value; if (choice === 'A') this.getField('ImageA').display = display.visible; if (choice === 'B') this.getField('ImageB').display = display.visible;

5
Reset and test the form

If you have a reset button, use its Properties > Actions tab to run hideImages(); after its Reset a form action. Save the PDF, close and reopen it in Acrobat or Reader, then test each radio button and the reset button.

Control image button fields with Acrobat JavaScript
Viewer support matters: Browser PDF viewers may ignore form scripts or handle refresh differently. If visibility does not change in Acrobat or Reader, check that JavaScript is enabled and that the field names and export values match the script.
Free Microsoft Office alternative

View PDFs and Work with Office Files in WPS Office

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

View PDF documents alongside your other office filesOpen and edit compatible Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface to ease migration from Microsoft OfficeAccess a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the image remain visible after I reopen the PDF?

The field's visibility may not have been reset. Add a document-level script in Acrobat that sets each image field's display property to display.hidden when the document opens.

Can a browser PDF viewer run this script?

Browser support for Acrobat JavaScript varies, and some viewers do not run it. Open the saved PDF in Acrobat or Reader to test the form.

How do I hide all images when the form is reset?

In the reset button's Properties > Actions tab, add a Run a JavaScript action after Reset a form and call the function that sets the image fields to display.hidden.

Why does selecting a radio button not show the right image?

Check the radio buttons' export values in Properties and compare them with the values in the script. Also verify that the image button field names match the names passed to getField.