How to Use an Acrobat Form Field Value in the Save As Filename
Question details
The user wants to dynamically generate a PDF filename during the save process by extracting the text from a specific form field using Acrobat JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Automating the file saving process so that a fillable PDF form is automatically named based on user input, such as an invoice number or client name.
- Observed behavior
- The user needs to implement a JavaScript solution to read the field value and construct the filename, as this functionality requires specialized scripting and folder-level deployment.
Ensure you have administrative access to the computer, as implementing this solution requires installing a trusted folder-level JavaScript file on every local machine where the automated saving feature will be used.
Use a Trusted Folder-Level JavaScript
Create and deploy a custom JavaScript function in Acrobat's local JavaScripts folder to securely bypass restrictions on the saveAs method.
For security reasons, the saveAs method in Acrobat JavaScript cannot be executed directly from a document-level script without user intervention. To automate the saving process using a form field value, you must create a 'trusted function'.
This trusted function must be saved in a .js file and placed inside the local JavaScripts directory of the Acrobat installation. Once installed, the PDF document can call this trusted function to save itself silently or with a pre-filled filename.
Open your PDF form in Adobe Acrobat, enter Form Editing mode, and note the exact name of the text field you want to use for the filename (e.g., 'InvoiceNumber').
Open a plain text editor like Notepad. Write a script utilizing app.trustedFunction to safely wrap the saveAs method. The script should extract the field value using this.getField('InvoiceNumber').value and append it to your desired file path.
Save the text file with a .js extension (e.g., customSave.js). Move this file into the Adobe Acrobat JavaScripts folder on your computer. On Windows, this is typically located at C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\JavaScripts.
Back in your PDF form, add a 'Submit' or 'Save' button. In the button properties, set the action to 'Run a JavaScript'. Input the command to call your newly created trusted function, passing the document object as a parameter.
Manage and Edit PDF Forms Easily with WPS Office
If dealing with complex local JavaScript deployments and security restrictions is slowing down your document workflow, try WPS Office. It provides a comprehensive, lightweight suite with robust PDF editing and form-filling capabilities.
- 1. Download the software: Visit the official WPS website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the installer and follow the quick on-screen instructions to set up the suite on your computer.
- 3. Open and edit your PDFs: Launch WPS PDF to effortlessly open, fill out, and manage your form documents without needing complex scripts.

Frequently Asked Questions
Why can't I just use document-level JavaScript to save the PDF?
For security reasons, the saveAs command is strictly restricted. If allowed at the document level, a malicious PDF could automatically write files to your computer without permission. Therefore, Adobe requires a trusted folder-level script.
Where is the JavaScripts folder located on a Mac?
On macOS, the Acrobat JavaScripts folder is typically located inside the application package. You can find it by right-clicking the Adobe Acrobat app in your Applications folder, selecting 'Show Package Contents', and navigating to Contents > Resources > JavaScripts.
Can I use this automated saving method on mobile devices?
No, folder-level JavaScripts for the saveAs function are generally only supported on desktop versions of Adobe Acrobat. Mobile PDF readers typically do not support executing these advanced local scripts.
How do I extract a specific form field value using JavaScript?
You can extract the value using the getField() method. For example, the code 'var myName = this.getField("ClientName").value;' will store the text entered in the "ClientName" field into the variable.




