How to Use PDF Form Fields to Create a File Name on Save
Question details
The user wants to automatically generate a file name for a PDF document based on the values entered into specific form fields during the saving process.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Filling out an interactive PDF form and needing a standardized, dynamic file name (like an invoice number or client name) to be applied automatically upon saving.
- Observed behavior
- Standard 'Save As' operations cannot automatically extract form field values to construct the file name, requiring manual renaming.
Ensure you have permission to edit the PDF form and that your PDF software allows the execution of JavaScript, as automated renaming requires custom scripting.
Use a Scripted Form Button to Save a Copy
Create a custom button within the PDF that executes an Acrobat JavaScript action to read the required form fields, format them into a valid name, and save a copy of the file.
By default, PDF software cannot rename the currently open file in place. However, you can bypass this limitation by adding a JavaScript-powered button that reads the data you typed into the form, generates a dynamic file name, and uses the 'saveAs' method to output a copy of the document.
Keep in mind that silently writing files to a local drive via JavaScript presents a security risk. You may need to configure folder-level security permissions or set up a trusted function in your PDF reader to allow the script to execute successfully.
Open your interactive document in your PDF editor (such as Adobe Acrobat Pro) and access the 'Prepare Form' or 'Form Editing' toolset.
Select the 'Button' tool from the form controls menu and place the new button onto your PDF page where users can easily click it after filling out the form.
Right-click the button, select 'Properties', and navigate to the 'Actions' tab. Choose 'Mouse Up' as the trigger, select 'Run a JavaScript' as the action, and click 'Add'.
In the JavaScript editor, write a script that retrieves your target field values (e.g., using this.getField('ClientName').value), concatenates them with your desired folder path, and executes the this.saveAs(filePath) function.
Exit form editing mode, fill in the target fields with test data, and click your new button to ensure a copy of the PDF is successfully saved with the dynamic file name.

Easily Manage and Save PDF Forms with WPS Office
If you are looking for an intuitive way to fill out, edit, and organize PDF forms without relying on complex JavaScript configurations, WPS Office provides a streamlined and highly compatible PDF editor.
- 1. Open your PDF form: Launch WPS Office, select the PDF tab, and open your interactive document.
- 2. Fill the fields: Simply click on the text fields, checkboxes, or dropdown menus to input your desired data accurately.
- 3. Save your document: Navigate to the top menu, click 'Save As', and manually type your standardized file name before selecting your preferred output folder.

Frequently Asked Questions
Can I automatically rename the original PDF file that is currently open?
No, standard PDF JavaScript APIs do not permit you to rename the exact file that is actively open and being viewed. You can only use scripts to save a duplicate copy of the document under a new name.
Why does my JavaScript 'saveAs' command do nothing when I click the button?
The 'saveAs' method is heavily restricted by modern PDF readers to prevent malicious files from being automatically downloaded to your system. To make it work, you generally must run the command through a trusted function defined within your application's folder-level scripts.
Is there a way to auto-name a PDF on save without using JavaScript?
Most standard PDF viewers do not include a built-in graphical feature to automatically pull form text into the 'Save As' dialogue box. Non-scripting solutions usually require third-party document management software, virtual PDF printers, or macro automation tools.




