Copy link to clipboard
Copied
Helly everyone,
As the title suggests I would like to place a button inside the pdf file which prompts the SaveAs function with generated filename based on the field values inside the pdf file. Then the user only needs to select the path. In the past I've made a JS function on a button with stores the pdf file automatically in a path but now I want the user to be able to decide where to store. Is that even possible?
I made the following script for auto name and auto save...
// splice supplier (get first word in field)
var supplier = this.getField("3").value;
// always cut after 10
var supplierNew = supplier.slice(0, 9);
// if space found, cut:
if (supplierNew.includes(" ")){
var supplierNewNew = supplierNew.split(" ", 1);
} else {
var supplierNewNew = supplierNew;
};
// make a file name from the field values
var fileName = this.getField("1").value + "_" + this.getField("Group2").value + "_" + this.getField("Dropdown4").value + "_" + supplierNewNew + "_" + this.getField("54").value;
fileName = fileName.replace("\\","");
fileName = fileName.replace("/","");
fileName = fileName.replace(":","");
fileName = fileName.replace("*","");
fileName = fileName.replace("?","");
fileName = fileName.replace("\"","");
fileName = fileName.replace("<","");
fileName = fileName.replace(">","");
fileName = fileName.replace("|","");
// get the path where the file is currently located
var filePath = this.path.replace(this.documentFileName, "");
// create the new full path
var newFullFilePath = filePath + fileName + ".pdf";
if ((this.getField("1").value.length < 1) || (this.getField("Group2").value.length < 1) || (this.getField("Dropdown4").value.length < 1) || (this.getField("3").value.length < 1) || (this.getField("54").value.length < 1)){
app.alert("Es sind nicht alle Pflichtfelder (*) ausgefüllt!");
} else {
try {
this.saveAs(newFullFilePath);
} catch (e) {
app.alert("Error! Could not save as: " + newFileName);
}};
Copy link to clipboard
Copied
Not possible.
Copy link to clipboard
Copied
I think you are right. Is it why the Acrobat Reader cannot communicate with the Windows SaveAs prompt?
Copy link to clipboard
Copied
Correct
Copy link to clipboard
Copied
Thank you for your response.
Copy link to clipboard
Copied
FYI I have found a workaround. With JS I save the file in /c/temp/ with the following function:
this.saveAs(filePath + fileName + ".pdf");
and after that I call
app.execMenuItem("SaveAs");
so that the user able to select a new path with the filename prefilled to the prompt