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

SaveAs is not a function

Community Beginner ,
Jan 04, 2017 Jan 04, 2017

Hello everybody,

i tried to a button in an Adobe Acrobat pdf form with javascript to automate the saveas function with the file name from a textfield.

I did a lot of research in the internet and found many examples and help postings so I know that I need folder level scripting because of security functions from adobe with the actual version of the reader.

folder level script:

myTrustedSaveAs = app.trustedFunction(function(vDoc,path)

{

app.beginPriv();

var myPath = "/C/Users/***username***/Downloads/test/" + "text1Value.pdf";

vDoc.saveAs({cPath: myPath, bCopy: true, bPromptToOverwrite: false});

app.endPriv();

});

button script:

var text1Value = this.getField("Objekt").value;

event.target.myTrustedSaveAs(event.target);

When I trie this scripts with the adobe reader it allways say "TypeError: event.target.myTrustedSaveAs is not a function" and I can't get that running.

Maybe someone can help me get this running

thank you for every help!

TOPICS
Acrobat SDK and JavaScript , Windows
2.8K
Translate
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 , Jan 05, 2017 Jan 05, 2017

Remove "event.target.".

Translate
LEGEND ,
Jan 04, 2017 Jan 04, 2017

You should call it like this instead:

myTrustedSaveAs(this, textValue);

and you have to change the function to use textValue when setting the path of the file to save.

Translate
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 Beginner ,
Jan 05, 2017 Jan 05, 2017

I tried to change it like you said but I get again the error: "TypeError: event.target.myTrustedSaveAs is not a function"

Translate
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 ,
Jan 05, 2017 Jan 05, 2017

That's not the code posted above.

Translate
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 Beginner ,
Jan 05, 2017 Jan 05, 2017

I don't know what you mean...maybe you can explain it

thanks

Translate
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
LEGEND ,
Jan 05, 2017 Jan 05, 2017

Whenever you make a change to a folder-level JavaScript file, you need to restart Acrobat for it to take effect.

Translate
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 Beginner ,
Jan 05, 2017 Jan 05, 2017

ok I did this between every test.

my scripts are now like this:

folder level:

myTrustedSaveAs = app.trustedFunction(function(vDoc)

{

app.beginPriv();

var myPath = "/C/Users/***USER***/Downloads/test/" + "text1Value.pdf";

vDoc.saveAs({cPath: myPath, bCopy: true, bPromptToOverwrite: false});

app.endPriv();

});

button click event:

var text1Value = this.getField("Objekt").value;

event.target.myTrustedSaveAs(this, text1Value);

and again I got the error: "TypeError: event.target.myTrustedSaveAs is not a function"

I don't know why it allways says not a function because I defined it in the folder level script

also I tried several times to log out and in from the windows profil and restart the complete pc...

Translate
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 ,
Jan 05, 2017 Jan 05, 2017

Remove "event.target.".

Translate
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 Beginner ,
Jan 05, 2017 Jan 05, 2017

thank you VERY mutch!!! it works now

I thougt this is needed to trigger the function...

sutch a little change and it works very fine and I am very happy now

thanks a lot to all of you for your help!

EDIT: Hab in meiner Eupforie jetzt erst gecheckt, dass du vermutlich eh Deutsch sprichst DANKE!!!

Translate
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 ,
Mar 19, 2017 Mar 19, 2017
LATEST

Hello,

Is it possible that you give the whole .js scripts and what you filled in the .pdf stamp ?

I created a dynamic stamp and want to save the document in a specific dir. with specific filename.

Thanks.

Translate
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
LEGEND ,
Jan 04, 2017 Jan 04, 2017

Also please randomize your function name - you have created a massive security hole in your system.

Translate
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 Beginner ,
Jan 05, 2017 Jan 05, 2017

thank you for the hint

Translate
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 ,
Jan 04, 2017 Jan 04, 2017

There's no need for the second parameter if you're specifying the path of the file in the trusted function.

Translate
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