Copy link to clipboard
Copied
Hello,
I have set up a PDF form which shall be stored under the name formed from the entries of two text fields via an implemented button. Saving the file works well now, but the user is not warned if a file with this name already exists.
I found several hints to a parameter called "bPromptToOverwrite", but unfotunately I can't get it included in the code of my script.
Does anyone know how to do it or what other possibility there could be?
Many thanks for any help!
Copy link to clipboard
Copied
You can do it by changing this line of your code:
doc.saveAs(path);
To this:
doc.saveAs({cPath: path, bPromptToOverwrite: true});
However, I would recommend you rename the path variable to something else, as there's already a property of the Document object with that name which can cause a conflict.
Copy link to clipboard
Copied
You have a bigger issue than that. You can't define the trusted function inside your button. That won't work.
It has to be located in a privileged context, like a folder-level script. If you can't do that then the whole issue is moot, as you won't be able to save the file at all using a script.
Copy link to clipboard
Copied
Hello try67,
thank you for your answer!
Saving the file worked without problems in the attached pdf-file.
I hope, there will be a solution for the rest too, for example with browseForFile, bPromptToOverwrite or enabling "Menu Items JavaScript Execution Privileges option"....?
Copy link to clipboard
Copied
It shouldn't work, unless you placed the file in a "trusted" folder or certified it.
If you don't do that you'll get this error message:
NotAllowedError: Security settings prevent access to this property or method.
App.trustPropagatorFunction:3:Field Speichern:Mouse Up
Copy link to clipboard
Copied
Yes, I declared the folder as trusted in the Acrobat-security-settings...
Copy link to clipboard
Copied
That explains it... If you're the only user of this form that's fine, but if you plan on sending it to others it's not going to work for them, unless they do the same.
Copy link to clipboard
Copied
Yes, I know....The form will be used on only 2 PCs, but from several different persons. Therefore I,m concerned, that the one or other will not be as careful as he/she should. There should be an alert in any manner...
Copy link to clipboard
Copied
You can do it by changing this line of your code:
doc.saveAs(path);
To this:
doc.saveAs({cPath: path, bPromptToOverwrite: true});
However, I would recommend you rename the path variable to something else, as there's already a property of the Document object with that name which can cause a conflict.
Copy link to clipboard
Copied
Hello try67,
you´re a hero!!
Works wonderful, exactly what I needed!
Thank you so much for your help!

