Copy link to clipboard
Copied
I am currently running 3 scripts on my save button that execute before the
Execute menue item > File> PDF>Save As
I want to be able set up script that will change the name of the original file for the user - so that they don't save their new .pdf over the template on accident.
currently my save button runs these scripts before the "execute menue item"
//locks the page
for (var i = 0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
this.getField(fname).readonly = true; // makes all fields readonly
}
//deletes my template
for (var p=this.numPages-1; p>=0; p--) {
for (var n=0; n<this.getPageNumWords(p); n++) {
if (this.getPageNthWord(p, n) == "Template") {
this.deletePages(p);
break;
}
}
}
//hides all my buttons
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="button") f.display = display.hidden;
}
Then executes my save as request.
Im hoping the code would go here. To change the name and then save as - instead.
I have this so far:
// Split Path into an array so it is easy to work with
var aMyPath = this.path.split("/);
// Remove old file name
aMyPath.pop();
// Add new file name
aMyPath.push("NewFileName.pdf");
// Put path back together and save
this.saveAs(aMyPath.join("/"));
Currently, everything runs but the file isn't saving under a new name.
Or is there a way to just push a suggested name into the save as?
Thanks everyone!
Copy link to clipboard
Copied
Thinking the answer is here?
https://community.adobe.com/t5/acrobat/save-pdf-file-name-as-field-name-in-pdf/td-p/7231510?page=1
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more