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

SaveAs is not a function

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 is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
January 5, 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...


Remove "event.target.".

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

Translate
Legend
January 4, 2017

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

Translate
heasde25642347
Participating Frequently
January 5, 2017

thank you for the hint

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

Translate
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"

Translate
try67
Community Expert
Community Expert
January 5, 2017

That's not the code posted above.

Translate