PDF Editing Issues

How to Save a PDF Form Using a Case Number as the Filename

Kushani NimanthikaKushani Nimanthika Nov 5, 2026 868 views

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.

How to Save a PDF Form Using a Case Number as the Filename
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.
Before you start

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.

Solution 1Recommended

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.

1
Create the Script File

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.

2
Install on Local Machines

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.

3
Configure the PDF Button

In your PDF form, add a custom button and assign a 'Run a JavaScript' action to it.

4
Call the Trusted Function

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 Local Folder Trusted Function
Important: This method requires the JavaScript file to be manually installed on every user's computer; it cannot be embedded directly into the PDF or fetched from a remote web server.
Efficient PDF Form Editing

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. 1. Open the Form: Launch WPS Office and open your interactive PDF form.
  2. 2. Fill the Data: Click into the form fields, such as the case number, and input the required information.
  3. 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.
Seamlessly fill out interactive PDF forms and save them locally in seconds.High compatibility with standard PDF formats and Adobe Acrobat elements.Lightweight alternative to heavy PDF software, loading documents instantly.Built-in PDF toolkit for converting, splitting, and merging files.
microsoft office alternative - wps office

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.