Save an Adobe Acrobat PDF with Read-Only Form Fields
Question details
The user needs a button script to save a renamed PDF with its form fields set to read-only.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF button uses form field values to determine the name of the saved file.
- Observed behavior
- The form fields become editable again when the saved PDF is reopened.
Open the PDF in Adobe Acrobat and locate the button's existing JavaScript action. Identify where the script builds the file name and calls saveAs.
Set all form fields to read-only before saving
Update the button script so the saved copy includes the read-only field properties.
In Acrobat, open Prepare a Form, select the button, and open its Properties. On the Actions tab, edit the existing JavaScript action.
After the script obtains the field values needed for the file name, but before its saveAs call, add: for (var i = 0; i < this.numFields; i++) { var field = this.getField(this.getNthFieldName(i)); if (field) field.readonly = true; }
Keep the existing saveAs call after the loop, then close the JavaScript editor and save the PDF. The save operation must run after the read-only properties are set.
Click the button, close the document, and reopen the newly saved file. Try entering text in several fields to confirm they remain read-only.

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 Office documents. Its format compatibility makes it easy to bring existing files into your workflow. It does not fix Acrobat button scripts or their save permissions.

Frequently Asked Questions
Why are my fields editable after I reopen the saved PDF?
The script may be setting the read-only properties after saveAs runs. In the button's JavaScript action, place the read-only loop before the saveAs call and test the newly saved copy.
How does the script find every form field?
Use this.numFields to iterate through the fields, this.getNthFieldName(i) to get each name, and this.getField(name) to retrieve the field before setting its readonly property.
Why does saveAs fail from my Acrobat button?
Scripted saveAs operations can be restricted by Acrobat security. Check whether the save operation is allowed in the script's execution context and whether the destination path and permissions are valid.
Does making a field read-only secure its contents?
No. The read-only property prevents normal form editing, but someone with permission to edit the form can change that property. Use appropriate PDF security controls if stronger protection is needed.




