Hi,
I am using Adobe reader 8.1.2. I am using Adobe livecycle designer to write the javascript for the button event. My requirment is when I click the button "Save" the Adobe form should be saved in a specific path. I am able to invoke the similar functionality using the menu event. Could you please help me to implement the similar functionality with the button event.When I click the button to save the Adobe form the following error message is displayed.
The error message is :Security settings prevent access to this property or method.
The below code is available in eDoc.js file @ C:\Program Files\Adobe\Reader 8.0\Reader\Javascripts
app.addMenuItem( { cName: "eDocSave", cUser: "Save eDoc", cParent: "File", cExec: "edocSave()", nPos: "Close"} );
function edocSave() {
app.alert("This is a begining");
var myDoc = event.target;
//app.alert("This is a first list");
var myDoc = event.target;
var strPath = "/c/Adobe/";
app.alert(strPath);
//var objField = myDoc.getField("F[0].P1[0].SaveLocation[0]");
//app.alert(objField);
var strFile = strPath + "test123.pdf";
app.alert(strFile);
try {
app.alert("Before Save As: " + strFile);
fnMakePDF(myDoc,"/c/Adobe/TestFile.pdf");
//myDoc.saveAs(strFile);
} catch (E) {
for (var i in E)
app.alert(i + ": " + E[i]);
}
}
fnMakePDF = app.trustedFunction( function (doc,outFile)
{
app.beginPriv();
mySaveAs(doc,outFile); // Save it (or overwrite old)
console.println("\nThere are " + doc.numFields + " Fields in this document");
//doc.closeDoc(true); // close the document
//doc = undefined;
app.endPriv();
return;
}); // END function fnMakePDF
mySaveAs = app.trustPropagatorFunction(function(doc,outFile)
{
app.beginPriv();
doc.saveAs({cPath: outFile});
app.endPriv();
});
The Javascript available for the button onClick event @ Adobe Livecycle Designer.
try
{
app.beginPriv();
var docinfo=event.target;
fnMakePDF(docinfo,strFileName );
app.endPriv();
}
catch (E) {
for (var i in E)
app.alert(i + ": " + E[i]);
}
Please let me know if there is any alternative approach to save the Adobe form using the onClick event on Button.
Thanks
Madhan
2. User written script may not be coded in the same manner as appliction supplied scripts. There are
3. There are significant differences between Acrobat's and Reader's furnctionality, especailly around the "save as" in a form.
For a user to use the "saveAs()" method for version , the user written code needs to be placed in an Acrobat/Reader application level JavaScript folder and the user must create a trusted function and use the privlage method.
All of this is contained in the Acrobat JavaScript documentation.
George Kaiser