I am having problems with the security restrictions of JS run in PDFXChange Editor. My goal is to have a button which when I click on it, it saves the made changes, creates a copy of the file, flattens forms and annotations and adds this document (its one page) as a document header to other document (which I chose from app.browseForDoc).
I made this function on my PC, it worked always, I was happy. However then I sent that PDF to my college and that code did not run at all. Error was:
Code: Select all
NotAllowedAccess: Security settings prevent access to this property or methodI googled the issue and implemented the code as privileged fuction and store in locally (should solve the issue). The loading of the function works, so there is an improvement. HOWEVER In the privileged function I need to open new file by app.openDoc and get the doc object. And this still doesnt work. See my privileged test function to addess the issue:
Code: Select all
global.trustedSimpleFcn = app.trustedFunction(function(originalDoc)
{
app.beginPriv();
var originalPath = originalDoc.path;
// Get the path for the temp file
var tempPath = app.getPath("user", "temp") + "/my_temp_pdf.pdf";
// This saves the original file as temp
originalDoc.saveAs(tempPath);
// Open original again
app.openDoc(originalPath);
// Open the temp to get the doc object
var tempDoc = app.openDoc(tempPath);
if (!tempDoc) {
app.alert("tempDoc is empty!", 0, 0, "Error");
app.endPriv();
return;
}
app.alert("tempDoc is provided!", 3, 0, "Info");
app.endPriv();
})
Code: Select all
global.trustedSimpleFcn(this);Thanks and regards,
Filip