• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

JavaScript SaveAS from form field help please.

New Here ,
Jul 02, 2018 Jul 02, 2018

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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

2.4K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 02, 2018 Jul 02, 2018

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.

Likes

Translate

Translate
Community Expert ,
Jul 02, 2018 Jul 02, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

Where did you place this code, exactly? Are you sure it's the exact same

error message?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

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?? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

What is the value of the "Customername" field?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

I just tested a document and the value is smith

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

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!:

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

What do you use in the trusted function?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

No, a script can't create a folder.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

LATEST

Darn.  I will stop wasting my time then.  Thankyou again!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines