Copy link to clipboard
Copied
I have read through multiple pages here and used various codes but am having no luck. The most common error I receive is a cPath unsupported error. I have place code in the trusted folder script area. I have tried various button codes but same results.
let me explain my unique situation and what I need to accomplish and maybe there is a simpler way. all I need is to have a for button simple enough. it needs when pressed by the user to either silently save as or bring up a dialog, preferably a dialogue that will save the filled pdf as a new name chosen from 2 or three form fields that have been filled out by the user with valid either number or letter characters. honestly it could even save the form as the same name but to a new folder named from just one form field and i would be able to live with that.
this will be used on only one pc on a closed network and the form will be saved to a local path. I understand I may still need trusted script which is fine but also that information may not apply since this is only on one pc and all local cant I just have a button script and I am using adobe acrobat pro dc and have the enhanced security settings set to trust the folder??
Any help would be greatly appreciated
something like this for my button script??
this.saveAs("/c/MyDocs/" + getField("Customername")).value;
but this returns unsupported cPath error:
UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:1:AcroForm:Save:Annot1:MouseUp:Action1
Your code is incorrect. It should be:
this.saveAs("/c/MyDocs/" + getField("Customername").value);
Also, does the value of the field end with ".pdf"? If not, it will fail.
Copy link to clipboard
Copied
Your code is incorrect. It should be:
this.saveAs("/c/MyDocs/" + getField("Customername").value);
Also, does the value of the field end with ".pdf"? If not, it will fail.
Copy link to clipboard
Copied
ok, so I changed it to ths:
this.saveAs("/c/MyDocs/" + getField("Customername").value + ".pdf" );
so it should be adding .pdf correct? but i receive the same error.
Copy link to clipboard
Copied
Where did you place this code, exactly? Are you sure it's the exact same
error message?
Copy link to clipboard
Copied
I have it placed in button properties run a javascript. I am now trying a different folder path:
this.saveAs("/c/Users/GaryLeePC/Documents/" + getField("Customername").value + ".pdf");
I am not usin a trusted function with this as i have enhanced security settings set to trust this folder. I know that part is working as if i undo the enhanced security settings in preferences the console gives me a security error. the error returned for this code snippet is:
UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:1:AcroForm:Save:Annot1:MouseUp:Action1
which is the same. where am I going wrong??
Copy link to clipboard
Copied
What is the value of the "Customername" field?
Copy link to clipboard
Copied
I just tested a document and the value is smith
Copy link to clipboard
Copied
Scratch that it works thankyou! I had a default value in the cutomer name field that had a : in it. got rid of it and it works now. thank you!:
Copy link to clipboard
Copied
What do you use in the trusted function?
Copy link to clipboard
Copied
Is it further possible to have this script also create a folder based on form field value? as it is setup currently it saves to a pre defined folder. could i add something like:
this.saveAs("/c/Users/GaryLeePC/Documents/getField("Customername").value" + getField("Customername").value + ".pdf");
this is an example and I know this doesn't work but is something similar possible or am I pushing my luck?
Copy link to clipboard
Copied
Update:
I gave changed code to:
this.saveAs("/c/Users/GaryLeePC/Documents/" + getField("Customername").value + "/" + getField("Customername").value + ".pdf");
trying to achieve having it create a folder and receive the error:
RaiseError: The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.
Doc.saveAs:1:AcroForm:Save:Annot1:MouseUp:Action1
===> The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.
Copy link to clipboard
Copied
No, a script can't create a folder.
Copy link to clipboard
Copied
Darn. I will stop wasting my time then. Thankyou again!