Hide an Acrobat PDF Action Button After Saving Under a New Name
Question details
Hide an Acrobat form action button in a renamed copy while keeping it visible in the original PDF template.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A user completes a PDF form and saves it under a different file name.
- Observed behavior
- The button should disappear in the renamed copy but remain visible in the original template.
Confirm the exact original PDF file name and the button's form field name in Acrobat's Prepare a Form tool. Make sure JavaScript is enabled in the Acrobat or Reader settings used to test the form.
Hide the button with an Acrobat Did Save script
Use a document action to compare the saved PDF's name with the template name and hide the button in renamed copies.
Open the template in Acrobat and select Tools > Prepare a Form. Select the button and check its exact field name in its properties.
Go to Tools > JavaScript > Set Document Actions and select the Did Save action.
Enter the following code, replacing Button1 with the exact field name and MyDoc.pdf with the original template file name, including its extension: var f = this.getField("Button1"); if (f && this.documentFileName !== "MyDoc.pdf") { f.display = display.hidden; }
Save the template with its original name. Complete a test copy, choose File > Save As, and give it a different name. The Did Save action should hide the button after the first save.
Choose File > Save again to store the changed field visibility, then close and reopen the renamed PDF to check the result.

Also hide the button when a renamed PDF opens
Add the same check as a document-level script if the button must be hidden when a renamed copy is reopened.
Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and support for common Office formats, making it easier to move existing files into your workflow. Use Acrobat for the document actions and JavaScript configuration described above.

Frequently Asked Questions
Why do I need to save the renamed PDF twice?
The Did Save action changes the button's visibility after the first save. Choose File > Save again to store that change in the renamed PDF.
How do I find the button's exact field name?
In Acrobat, open Tools > Prepare a Form, select the button, and check its field properties. Use that exact name in this.getField().
Can the button be hidden when someone opens a renamed copy?
Yes. Add the filename check under Tools > JavaScript > Document JavaScripts. Keep the Did Save action as well if the button should also disappear immediately after Save As.
Is checking the file name a secure way to restrict access?
No. A user can rename or edit the PDF, and a viewer may not run the JavaScript. Use appropriate access controls instead of relying on button visibility.




