Automatically Name and Save Acrobat PDF Forms Using Field Values
Question details
Determine how to name and save a PDF form using field values, clear the form afterward, and create folders from form data.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A user wants to automate saving completed fillable PDF forms with filenames and folders based on entered information.
- Observed behavior
- The desired workflow saves each completed form under a generated name and resets the fields for the next entry.
Check the exact field names in Acrobat's Prepare a Form tool and choose an existing destination folder. Confirm that you can install an Acrobat application-level JavaScript file; the example below uses a Windows folder named C:\Forms.
Use a trusted Acrobat script to save and reset the form
Use this approach when you control the Acrobat installation and want to save completed forms in an existing folder using a field value.
Acrobat restricts scripted file saving for security. A trusted application-level script can perform the save, but it must be installed on each Acrobat installation that runs the workflow. A script embedded in the PDF alone is not sufficient for an unrestricted save.
The example saves to an existing Windows folder and adds a timestamp to reduce filename collisions. It does not create folders. Use an external workflow if folders must be created from form values.
Open the PDF in Acrobat and select All tools > Prepare a form. Check the field name in its properties; the example uses a text field named CustomerName.
In Acrobat's application-level JavaScripts folder, create a .js file containing: var trustedFormSave = app.trustedFunction(function (doc, path) { app.beginPriv(); try { doc.saveAs({cPath: path}); } finally { app.endPriv(); } }); Restart Acrobat so the function is loaded. Follow Adobe's documentation to locate the application-level folder for your installation.
In Prepare a form, add or select a button. Open its properties, select Actions, choose Mouse Up and Run a JavaScript, then add: var field = this.getField('CustomerName'); var name = field ? String(field.value).replace(/[^a-zA-Z0-9_-]/g, '_') : ''; if (!name) { app.alert('Enter a customer name first.'); } else { try { trustedFormSave(this, '/C/Forms/' + name + '_' + new Date().getTime() + '.pdf'); this.resetForm(); } catch (e) { app.alert('Could not save the form: ' + e); } }
Create C:\Forms if it does not already exist, enter a value in CustomerName, and click the button. Open the saved PDF from C:\Forms to verify the filename and form data; the open form should be reset after the save succeeds.

Work with PDF forms and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Open existing files and save them in compatible formats as you move between applications. It does not replace Acrobat's trusted-script automation.

Frequently Asked Questions
Can Acrobat name a saved PDF from more than one form field?
Yes. In the button's Run a JavaScript action, read each field with this.getField('FieldName').value, sanitize the values, and join them to build the filename passed to the trusted save function.
Will resetting the form erase the data in the saved PDF?
In the example, this.resetForm() runs after saveAs succeeds, so the saved copy should retain the entered data while the open form is cleared. Open the saved copy to verify it before using the workflow.
Can Acrobat JavaScript create a folder for each form entry?
Acrobat form JavaScript does not provide general-purpose folder creation. Create the destination folder beforehand or use an external workflow to create and organize folders.
Why does the save button fail on another computer?
Check that the trusted application-level script is installed and Acrobat has been restarted, that the destination folder exists, and that the user has permission to write to it. Acrobat security settings and Reader restrictions may also prevent the operation.




