Follow my instructions above to get the correct syntax for the folder name.
I tried the following;
The correct syntax I got, based on the debugger for "this.path" returned
/HAUCACAM0007VS/Shares/Marketing_bridge/Darin/`MasterTracker/EventRequestForms/1/test.pdf
so I changed the code from this
// determine the directory path for the current document
var directory = this.path.substring(0, this.path.lastIndexOf('/') +1);
to this
// determine the directory path for the current document
var directory = "/HAUCACAM0007VS/Shares/Marketing_bridge/Darin/`MasterTracker/EventRequestForms/1/"
and it worked. I swear I tried that, and a few variations before.
Very interesting. I can send myself this PDF, open it without saving, click the save and it points to my directory I wanted.
Yay! Solved!
Thank you try67!
Again, for the sake of people googling how to do this...
---------------------------
I pasted this code into a text file, saved it as a javascript (.js file), in the following locations Program Files > Adobe > Acrobat > Javascript, I also pasted it into the folder where I will be saving the file.
- var mySaveAs = app.trustedFunction(
- function(oDoc, cPath, cFlName) {
-
- cPath = cPath.replace(/([^/])$/, "$1/");
- try {
- app.beginPriv();
- oDoc.saveAs(cPath + cFlName);
- app.endPriv();
- } catch (e) {
- app.alert("Error During Save - " + e);
- }
- }
- );
Then, I created a button, added a javascript to it. the "this.getField's are looking for field names in my PDF, "RequestedBy" is a field in my PDF that has my sales managers name, it then adds a space beside it (+ " " +), then goes to the next field I want. so when I fill out the pdf, it then saves it as SalesManager EventName June 1 2015.pdf.
- // determine the directory path for the current document
- var directory = "/HAUCACAM0007VS/Shares/Marketing_bridge/Darin/`MasterTracker/EventRequestForms/1/"
- if (typeof(mySaveAs) == "function") {
- mySaveAs(this, directory, this.getField("RequestedBy").value + " " + this.getField("NameofEvent").value + " " + this.getField("EventStartmdyy").value + ".pdf");
- } else {
- app.alert("Missing Save Function. Please contact forms administrator ");
- }
Hope that helps anyone else looking to do this, it's fairly easy once you know where to save the javascripts (and what to put in it), then edit another javascript code to meet your needs.
Thank you!