Function app.openDoc not returning Doc object although run in privileged function
Hello,
I would very much appreciante your help. I have a privileged function stored on my local PC:
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") + "/esc_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
this.disclosed = true; // Because I heard it must be disclosed ??
app.openDoc(originalPath);
var tempDoc = app.openDoc(tempPath);
if (!tempDoc) {
app.alert("tempDoc is empty!", 0, 0, "Error");
app.endPriv();
return "";
}
app.endPriv();
app.alert("tempDoc is provided!", 0, 0, "Info");
return tempDoc.documentFileName;
})I am basically trying to save a copy of the current document as temp (and later manipulate it, flatten form and move it as a first page to other document, like a document header). For that I need to open a document and get the document object 'tempDoc' to be able to work with it.
I call this privileged function in button like this:
console.println(global.trustedSimpleFcn(this));and tempDoc is empty. However if I run this one line of code in console, the tempDoc is provided ALTHOUGH this is run inside the privileged function. Why is there a difference? How can I fix it?
Regards,
Filip
