PDF Editing Issues

Prevent Adobe Acrobat JavaScript from Overwriting Duplicate Files

Adam DavisAdam Davis Nov 19, 2026 868 views

Question details

The user needs to save completed PDF forms to a shared drive without overwriting files that have the same generated name.

Prevent Adobe Acrobat JavaScript from Overwriting Duplicate Files
Product
Adobe Acrobat JavaScript
Device & OS
not provided
Scenario
A PDF form builds its output filename from form fields and saves completed copies to a shared drive.
Observed behavior
When a filename already exists, selecting No in the overwrite prompt prevents the save but produces a JavaScript security error.
Before you start

Confirm that users can write to the shared folder and identify the form script that calls saveAs. Check whether the save operation requires a trusted Acrobat JavaScript function in your environment.

Solution 1Recommended

Prompt before overwriting and handle the save error

Use the overwrite prompt to let users protect an existing file, then handle an unsuccessful save in the script.

1
Find the save action

In Acrobat, open the form's save button action or other JavaScript action that calls saveAs.

2
Enable the prompt

Set the saveAs parameter bPromptToOverwrite to true so Acrobat asks before replacing an existing file.

3
Handle unsuccessful saves

Wrap the saveAs call in a try/catch block. In the catch block, tell the user that the file was not saved and offer a way to choose or generate another name; retain error details for troubleshooting.

4
Test the prompt

Save a form using an existing filename, select No in the overwrite prompt, and confirm that the original file remains unchanged and the user receives a clear message.

Prompt before overwriting and handle the save error
Check other save failures: An exception can also indicate a permission, path, or security problem. Do not assume every caught error means the user declined an overwrite.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility helps you move between common files, although it does not fix Acrobat JavaScript save errors.

Open PDFs and use basic annotation toolsCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight software for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Does selecting No in the overwrite prompt save the form under another name?

No. Selecting No prevents that overwrite, but the script must provide another filename and retry the save if the user wants to keep a completed copy.

How do I make Acrobat ask before replacing a file?

In the JavaScript action that calls saveAs, set bPromptToOverwrite to true. Test it with a filename that already exists.

Why does the form still show a security error after I decline the overwrite?

The unsuccessful save can raise a JavaScript exception. Wrap saveAs in try/catch and check the error details, because permissions, paths, and Acrobat security restrictions can also cause failures.

Is checking for an existing file enough when several people save at once?

Not necessarily. Two users can check the same name before either saves. Use a managed component that reserves filenames atomically when concurrent saves are possible.

Can WPS Office fix the Acrobat JavaScript error?

No. The error belongs to the Acrobat JavaScript workflow. WPS Office is an alternative for working with PDFs and Office files, but the Acrobat script and its permissions must be addressed in Acrobat.