How to Save a PDF Form Using a Case Number as the Filename
Question details
The user wants to configure a PDF form button to automatically save the file using a dynamically entered case number as its filename without relying on a web-hosted JavaScript file.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating a custom button in a PDF form to auto-save the document locally using a specific field value.
- Observed behavior
- The workflow requires privileged JavaScript execution, meaning standard scripts embedded directly in the PDF cannot silently save files to the local drive due to security restrictions.
Ensure you have administrator access to the local computers where the PDF will be used, as setting up trusted functions requires placing JavaScript files in protected installation directories.
Use a Local Folder Trusted Function
Create and deploy a startup JavaScript file containing a trusted function to bypass security restrictions and save the file.
Because saving a file to a local drive without a prompt is a privileged operation in standard PDF viewers like Adobe Acrobat, you cannot execute it directly from a document-level script. You must define a 'trusted function' in a folder-level JavaScript file installed on every user's machine.
Create a plain text file ending in .js (e.g., saveCustom.js) and write a JavaScript trusted function inside this file that invokes the save action using the required security wrapper.
Place the .js file into the PDF application's local JavaScripts folder (e.g., C:\Program Files\Adobe\Acrobat DC\Acrobat\JavaScripts) on each computer that will use the form.
In your PDF form, add a custom button and assign a 'Run a JavaScript' action to it.
Write a short script for the button that reads the case number field value and passes it as an argument to the trusted function you defined in the local file.

Use a Server-Side Process via Submit Button
Send the form data to a web server where a script handles naming and saving the document.
Instruct Users to Save Manually
Provide clear instructions within the PDF for users to manually save the file using the case number.
Easily Fill and Manage PDF Forms with WPS Office
While complex automated JavaScript saves require heavy setup and local installation, WPS Office provides an intuitive, lightweight solution for filling out, managing, and saving PDF forms smoothly without extensive configuration.
- 1. Open the Form: Launch WPS Office and open your interactive PDF form.
- 2. Fill the Data: Click into the form fields, such as the case number, and input the required information.
- 3. Save with Ease: Click 'Menu' > 'Save As' and type your case number as the filename to securely save your document to your desired location.

Frequently Asked Questions
Why doesn't the JavaScript saveAs function work directly from a PDF button?
For security reasons, PDF readers restrict document-level scripts from writing directly to the user's hard drive without prompting. To perform a save via a script silently, the script must be executed as a 'trusted function' installed in the application's local directory.
Can I host the trusted JavaScript file on a web server?
No, standard PDF security architectures require the startup JavaScript file to be physically located in the local application's designated JavaScripts folder to grant it elevated execution privileges. Web-hosted scripts are treated as untrusted.
Are there alternatives to Acrobat for editing PDF forms?
Yes, you can use software like WPS Office to open, fill out, and manually save interactive PDF forms with full formatting compatibility, completely bypassing the need for complex localized scripts.




