This content has been marked as final. Show 6 replies
use "this" with extreme care, because its meaning changes.
What you should probably do is pass the document you want to save as a
parameter to the trusted function.
However, I don't understand your statement "My trusted function works
fine." Surely, it isn't?
If I run:
var JSRename = app.trustedFunction(function(myinfo)
this.saveAs("/c/hold/"+ myinfo +".pdf");
this.closeDoc(true); // close the doc, no notification
cEnable: "event.rc = (app.doc != null);",
A menu button will appear and when I click it the active PDF docuemnt will be saved to the C:\hold\ folder as myTestDoc.pdf.
I will do some alerts to check id the data in the Dialog is being passed to the trusted function.
> If I run
I did my testing in the console and all was ok untill I saved my JS and tried to run it at folder-level. I'm now making changes to the script which is folder-level.
before the line this.saveAs("/c/hold/"+ myinfo +".pdf");
I tried app.alert(myinfo); and the alert worked. So the script does not know what the active(this) pdf is.
Thanks PDL I'll look at event.target if I find a way to tell it select the active PDF then the script should work.
event.target.saveAs("/c/hold/"+ myinfo +".pdf");
did the trick.
Now that it's working I've moved the destination to a server we have by using:
event.target.saveAs("/server_name/folder_on_server/"+ myinfo +".pdf");
This works fine on PC but Mac's don't like it. I've tried
I made a slight mistake in my previous post.
for the PC I use
event.target.saveAs("/server_name/share_name/folder_in_share/"+ myinfo +".pdf");
I found this works on the Mac
event.target.saveAs("/share_name/folder_in_share/"+ myinfo +".pdf");