How to Save a PDF Using Form Fields as the Filename
Question details
The user wants to configure a PDF form so that clicking a Save button automatically generates and applies a filename based on specific form fields, such as Name or Date.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form and attempting to automate the file naming convention for end-users saving the document.
- Observed behavior
- PDF standard security prevents a document from forcing the 'Save As' dialog to use a specific, automatically generated filename without a locally installed trusted script.
Understand that standard PDF security protocols prevent a document from arbitrarily writing files to a user's local system. Generating automatic filenames requires either a locally installed folder-level script or prompting the user to manually enter a suggested name.
Prompt the User with a Suggested Filename via JavaScript
Since you cannot force the Save As dialog to use a specific name universally, the safest approach is to extract the form field values and prompt the user to copy the suggested filename.
This method is universally compatible because it does not require modifying the end-user's local software installation. It utilizes basic PDF JavaScript to show a popup with the desired name.
Open your PDF form in editing mode, add a 'Button' form field, and label it 'Save'.
Right-click the button, select 'Properties', go to the 'Actions' tab, choose 'Run a JavaScript' from the Select Action dropdown, and click 'Add'.
Enter a script that concatenates your desired fields, for example: var suggestedName = this.getField('Name').value + '_' + this.getField('Date').value + '.pdf';
Add code to alert the user: app.alert('Please save the file as: ' + suggestedName); followed by app.execMenuItem('SaveAs'); to open the dialog.

Use a Folder-Level Trusted Script for Silent Saving
If you control the computers of all users (e.g., in an internal corporate network), you can install a trusted script to bypass security warnings and save the file silently.
Fill and Manage PDF Forms Easily with WPS Office
While automated local saving scripts require complex setup and bypass security, WPS PDF provides an intuitive, user-friendly interface for editing, filling, and managing PDF forms securely. Easily save, organize, and share your PDF documents across all platforms.
- 1. Open the PDF Form: Launch WPS Office and open your interactive PDF form directly in the WPS PDF editor.
- 2. Fill Form Fields: Click into the form fields such as Name, Date, or text boxes to input your data securely.
- 3. Save with Custom Name: Click 'Menu' and select 'Save As' to manually apply your preferred file naming convention based on the form data.
- 4. Sync to Cloud: Save the file directly to WPS Cloud to access your filled forms seamlessly across your computer and mobile devices.

Frequently Asked Questions
Can I force a user's computer to save a PDF without the Save As dialog appearing?
No, standard PDF security prevents a document from silently saving files to a local drive. This is designed to protect users from malicious file downloads. Silent saving requires a locally installed trusted script on that specific machine.
What JavaScript method triggers the native Save As dialog in a PDF?
You can trigger the native Save As dialog by executing the command app.execMenuItem('SaveAs'); within your document-level or button JavaScript action.
Why doesn't the this.saveAs() function work in my interactive PDF?
The this.saveAs() function is restricted for security reasons. It will fail if called directly from an interactive form button unless executed during a batch process, from the console, or via a trusted function installed locally on the user's system.




