Copy link to clipboard
Copied
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");
};
}
Copy link to clipboard
Copied
Does it work if you run the saveAs command, with the same file path value, from the Console?
Copy link to clipboard
Copied
I'm struggling to find a way to access the console in Reader DC. It has appeared to report errors when saving but I can't find a way to open it.
Copy link to clipboard
Copied
If you can't press Ctrl+J you can use a script attached to a button that runs this code:
console.show();
Copy link to clipboard
Copied
Also, make sure Protected Mode is off. Can't possibly work if it is on (it's designed to stop this sort of thing).
Copy link to clipboard
Copied
That was it! Protected mode was still on. Thanks try67 and Test Screen Name for your help, its very much appreciated.
Copy link to clipboard
Copied
Ooops, spoke too soon. It seemed to be working but then I ran into this error.
"Error During Save - RaiseError: the file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."
Copy link to clipboard
Copied
What's the full path you're trying to save it under?
Copy link to clipboard
Copied
Right, seem to have got to the bottom of it. It was an issue, like you asked about, with the file path. Windows 11 has a different file path structure for Sharepoint folders and reading the full path was slightly ambiguous on the tablet. I copied it into Notepadd++ and realised what seemed to be one folder down in windows exploere was not acctually that but somehow a virtualised folder for want of a better term. so what I though was
"/C/Users/Tech Department/LGT&OH Ltd/Health & Safety - Venue Information/Site Inductions/Completed Induction Forms/"
was in fact:
"/C/Users/Tech Department/LGT&OH Ltd/Health & Safety - Venue Information - Site Inductions/Completed Induction Forms/"
Now I have the corrrect location I have reformated the address for acroabt and everything is working. Thank you again guys.