Skip to main content
heasde25642347
Participating Frequently
January 4, 2017
Answered

SaveAs is not a function

  • January 4, 2017
  • 3 replies
  • 2714 views

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!

This topic has been closed for replies.
Correct answer Bernd Alheit

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


Remove "event.target.".

3 replies

try67
Community Expert
Community Expert
January 4, 2017

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

Legend
January 4, 2017

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

heasde25642347
Participating Frequently
January 5, 2017

thank you for the hint

Inspiring
January 4, 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.

heasde25642347
Participating Frequently
January 5, 2017

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

try67
Community Expert
Community Expert
January 5, 2017

That's not the code posted above.