This content has been marked as final.
Show 6 replies
-
1. Re: JS Rename PDF using app.trustedFunction()
(Aandi_Inston) Aug 17, 2008 11:21 PM (in response to John.Kordas)Look up the definition of "this" in the JavaScript reference. You must
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?
Aandi Inston -
2. Re: JS Rename PDF using app.trustedFunction()
John.Kordas Aug 18, 2008 3:10 PM (in response to John.Kordas)Hi Aandi,
If I run:
var JSRename = app.trustedFunction(function(myinfo)
{
app.beginPriv();
this.saveAs("/c/hold/"+ myinfo +".pdf");
this.closeDoc(true); // close the doc, no notification
app.endPriv();
});
app.addToolButton({
cName: "JSRename",
cLabel: "JSRenamePDF",
cEnable: "event.rc = (app.doc != null);",
cExec: "JSRename('myTestDoc');"});
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. -
3. Re: JS Rename PDF using app.trustedFunction()
Patrick Leckey Aug 18, 2008 3:35 PM (in response to John.Kordas)> If I run
Where are you testing this, in the console? From a folder-level JavaScript, you may be better off using event.target to reference the currently active PDF. -
4. Re: JS Rename PDF using app.trustedFunction()
John.Kordas Aug 18, 2008 5:03 PM (in response to John.Kordas)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. -
5. Re: JS Rename PDF using app.trustedFunction()
John.Kordas Aug 18, 2008 7:34 PM (in response to John.Kordas)Thanks PDL,
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
\/\/\server_name/folder_on_server/
and
\\server_name\folder_on_server\
Any suggestions? -
6. Re: JS Rename PDF using app.trustedFunction()
John.Kordas Aug 18, 2008 10:17 PM (in response to John.Kordas)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");
Cheers.

