Fix Acrobat saveAs JavaScript Not Working in PDF Form Buttons
Question details
The user is unable to execute a saveAs command via JavaScript tied to a PDF form button, despite other functions like email working.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Attempting to save a PDF form to a local drive using a JavaScript button after successfully validating required fields.
- Observed behavior
- The saveAs operation appears to do nothing, often failing silently without completing the save process.
Press Ctrl+J (Windows) or Cmd+J (Mac) to open the Acrobat JavaScript Console to check for hidden syntax or execution errors before modifying your script.
Verify and Correct the saveAs Script Implementation
Ensure that your script actually contains the doc.saveAs function and is not failing due to preceding validation errors.
Often, a script might successfully execute a mailDoc command but lack the actual saveAs implementation. Additionally, if a required-field validation fails, the script execution halts before it ever reaches the save command.
Enter Form Editing mode in Acrobat. Right-click the button that is failing and select 'Properties'.
Navigate to the 'Actions' tab, select 'Run a JavaScript' under the Select Action dropdown, and click 'Edit'.
Verify that your script explicitly includes the save command, such as `this.saveAs("/c/temp/myform.pdf");`. Ensure the file path syntax is correct for Acrobat JavaScript (using forward slashes).
Temporarily comment out the validation and email codes to test the saveAs function in isolation. Watch the JavaScript Console for any errors.

Configure Acrobat Privileged Locations
Acrobat's Enhanced Security prevents scripts from saving files to unauthorized directories silently.
Fill and Save PDF Forms Easily with WPS Office
Avoid the hassle of debugging complex JavaScript and security settings. WPS Office provides an intuitive, built-in PDF editor that allows you to easily fill, sign, and save interactive PDF forms without needing custom button scripts.
- 1. Install WPS Office: Download and install the free WPS Office suite on your device.
- 2. Open Your PDF Form: Launch WPS PDF and open the interactive PDF form you need to fill out.
- 3. Fill Out the Fields: Click into the form fields, checkboxes, and dropdowns to complete your document easily.
- 4. Save Instantly: Click the 'Save' icon in the top left corner or press Ctrl+S to save your completed form directly to your preferred folder.

Frequently Asked Questions
Can the free Adobe Reader execute the saveAs JavaScript function?
By default, the free version of Adobe Reader cannot execute the saveAs JavaScript function due to strict security restrictions. The document must have specific extended rights applied by Acrobat Pro for this to work in Reader.
Why does my PDF script send an email but fail to save the file?
If the script successfully executes 'mailDoc' but doesn't save, the code may be missing the 'doc.saveAs()' command entirely, or an Acrobat security restriction blocked the silent save operation.
How do I format file paths for Acrobat JavaScript?
Acrobat JavaScript requires device-independent paths using forward slashes. For example, a Windows path like 'C:\Documents\file.pdf' must be written as '/c/Documents/file.pdf' in the script.




