How to Automatically Save a PDF Form with a New Filename on Close
Question details
The user needs to configure a PDF form to automatically save a copy with a new, timestamped filename when the document is closed.

- Product
- Adobe Acrobat PDF
- Device & OS
- not provided
- Scenario
- Managing repetitive PDF form submissions where each completed form must be saved with a unique, dynamic filename to prevent overwriting the original template.
- Observed behavior
- By default, PDF forms do not automatically create a timestamped filename on close without the implementation of custom JavaScript or external workflows.
Ensure you have basic knowledge of JavaScript and check that your PDF application's security settings permit document-level scripts to execute file-saving actions.
Implement Document-Level JavaScript in Adobe Acrobat
Add a custom script to the document's 'Will Close' action to read form values, generate a timestamp, and trigger a Save As operation with the new filename.
To achieve automatic saving with a new filename, you must embed a custom JavaScript into the PDF's document actions. This script will trigger exactly when the user attempts to close the file.
Keep in mind that modern PDF readers have strict security protocols. Scripts attempting to write files to a local drive might require folder-level trust or specific user permissions to execute without being blocked.
Open your PDF form in Adobe Acrobat Pro. Go to 'Tools', scroll down to 'JavaScript', and select it.
Click on 'Document Actions' in the toolbar. Select 'Document Will Close' from the list of actions and click the 'Edit' button.
Write a JavaScript code that fetches the required string (e.g., using `this.getField('FieldName').value`), generates a date string, and uses the `this.saveAs()` method with your specified local directory path and new filename.
Save your script and close the dialog. Fill in the required form fields, then attempt to close the PDF document to verify if the file automatically saves to the designated folder with the new timestamped name.

Fill and Save PDF Forms Easily with WPS Office
While setting up custom JavaScript in Acrobat can be complex and prone to security blocks, WPS Office provides a highly intuitive PDF editor. You can effortlessly fill out interactive PDF forms, manage fields, and use the quick 'Save As' feature to organize your documents with custom names without needing coding knowledge.
- 1. Open the PDF Form: Launch WPS Office and open your interactive PDF form document.
- 2. Fill Out Data: Use the 'Form' tab to easily navigate and input your data into the interactive text fields, checkboxes, and dropdowns.
- 3. Trigger Save As: Once the form is completed, click on the 'Menu' button in the top left corner and select 'Save As', or simply press Ctrl+Shift+S on your keyboard.
- 4. Rename and Save: Type your desired unique identifier or timestamp into the File Name box, choose your destination folder, and click 'Save'.

Frequently Asked Questions
Why is my PDF JavaScript saveAs function not working?
Security restrictions in most modern PDF viewers (like Adobe Acrobat or Acrobat Reader) prevent scripts from silently saving files to the hard drive to protect users from malicious activity. To use this function, you usually need to configure trusted folders or utilize a folder-level script that grants elevated privileges.
Can I auto-save a PDF form without using JavaScript?
No, standard PDF formats do not have a built-in 'auto-save with new name on close' feature. You must either use JavaScript within the PDF or rely on an external document management system or workflow automation tool to rename and route files after they are submitted.
How do I extract a form field value to use in the filename?
In Adobe Acrobat JavaScript, you can extract a field's value using the syntax: var myName = this.getField('FieldName').value; You can then concatenate this variable with a date string and the file extension to construct your new filename for the saveAs() function.




