Copy link to clipboard
Copied
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!
Remove "event.target.".
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I tried to change it like you said but I get again the error: "TypeError: event.target.myTrustedSaveAs is not a function"
Copy link to clipboard
Copied
That's not the code posted above.
Copy link to clipboard
Copied
I don't know what you mean...maybe you can explain it
thanks
Copy link to clipboard
Copied
Whenever you make a change to a folder-level JavaScript file, you need to restart Acrobat for it to take effect.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
Remove "event.target.".
Copy link to clipboard
Copied
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!!!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Also please randomize your function name - you have created a massive security hole in your system.
Copy link to clipboard
Copied
thank you for the hint ![]()
Copy link to clipboard
Copied
There's no need for the second parameter if you're specifying the path of the file in the trusted function.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more