Trusted Functions in Reader on a Windows 11 tablet.
I have a form with a button to check through the form and save it using two field values combined as the name. For this I created a Save As Trusted Function (following instructions from here: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript/) which all worked fine on my Windows 10 PC using DC Pro. The idea is to run the forms from a tablet at the entrance to our building. When I transferred everything across to the tablet running windows 11 the Save As function no longer works. I have placed my Trusted Function script in what I understand to be the correct folders:
C:\Prgram Files\Adobe\Acrobat DC\Acrobat\Javascripts
and:
C:\Users\*this user*\AppData\Roaming\Adobe\Acrobat\DC\Javascripts
I get this error when I press the save button:
“Error During Save – NotAllowedError: Security settings prevent access to this propert or method.”
Here are my scripts.
Folder Lever – trusted function script:
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);
}
});
Save As function from the button:
var recordFileName =
this.getField("Company").valueAsString + " " + this.getField("startDate").valueAsString;
console.println("recordFileName = " + recordFileName);
//set all fields as read only
for (var k = 0; k < this.numFields; k++) {
this.getField(getNthFieldName(k)).readonly = true;
};
//save file to folder
var directory = "/c/Users/Tech Department/LGT&OH Ltd/Health & Safety - Venue Information - Documents/Site Inductions/Completed Induction Forms/"
if (typeof(mySaveAs) == "function") {
mySaveAs(this, directory, recordFileName + ".pdf");
app.openDoc("/c/Users/Tech Department/LGT&OH Ltd/Health & Safety - Venue Information - Documents/Site Inductions/Master Forms/Contractor Induction.pdf");
} else {
app.alert("Missing Save Fucntion. Please contact forms administrator");
};
}
