PDF Editing Issues

Hide and Show an Image With a Button in Adobe Acrobat

Amos GikundaAmos Gikunda Nov 19, 2026 868 views

Question details

The user wants an Acrobat form button to hide a PNG image on one click and show it again on the next.

Hide and Show an Image With a Button in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form contains an image and a button that should toggle the image's visibility.
Observed behavior
The desired result is for the same button to alternate the image between hidden and visible.
Before you start

Open the PDF in a version of Adobe Acrobat that can edit forms, and have the PNG file available. The image must be placed in an image field for the button script to control it.

Solution 1Recommended

Toggle an Acrobat Image Field With a Button Script

Use a Mouse Up JavaScript action to switch an image field between visible and hidden each time the button is clicked.

1
Create an image field

Open All tools > Prepare a form, select the image field tool, and draw a field where the PNG should appear. If the original PNG is a separate page image, remove it or replace it with the image field so it does not remain visible.

2
Import the PNG

Close Prepare a form, click the new image field, and select the PNG file. Reopen Prepare a form and check the field name in the Fields list or field properties.

3
Add a button action

In Prepare a form, open the button's Properties and select the Actions tab. Set Select Trigger to Mouse Up, choose Run a JavaScript, and click Add.

4
Enter the toggle script

In the JavaScript editor, enter: var f = this.getField("Image1_af_image"); f.display = f.display == display.visible ? display.hidden : display.visible; Replace Image1_af_image with the actual name of the image field, then save the action.

5
Test the button

Close Prepare a form and click the button twice: the image should disappear on the first click and return on the second. Save the PDF after testing.

Toggle an Acrobat Image Field With a Button Script
Visibility and viewer support: Hiding the image leaves its page area blank; surrounding content does not reflow. The toggle requires a PDF viewer that supports Acrobat JavaScript and has it enabled.
Free Microsoft Office alternative

Work With PDFs and Office Files in WPS Office

WPS Office is a free, lightweight alternative for everyday PDF and Office work, with a familiar interface and support for common Microsoft Office formats to help you migrate existing files. Use Adobe Acrobat to create and test the JavaScript image toggle described above.

Open and annotate PDFs in a familiar workspaceCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFree and lightweight for everyday document workMove between documents, spreadsheets, and presentations in one application
QA img-9

Frequently Asked Questions

How do I find the image field name for the script?

Open All tools > Prepare a form and inspect the Fields list or the image field's properties. Use the exact field name inside this.getField(), including any suffix.

Can the script hide a PNG placed directly on the PDF page?

The script controls a form field, not a separate page image. Add the PNG to an image field in Prepare a form and use that field's name in the script.

Why does the button not work in another PDF viewer?

The viewer may not support Acrobat JavaScript or may have JavaScript disabled. Test the saved form in Acrobat and check Preferences > JavaScript for the JavaScript setting.

Will the text move into the space when the image is hidden?

No. Changing the image field's display property hides the field but leaves its page area blank; the surrounding PDF content does not reflow.