Copy link to clipboard
Copied
Pre-created a protection policy with the name "MySecurityPol", and run this code from the console in Acrobat Pro DC, but there is a syntax error! What am I doing wrong?
var DoApplyMySecurity = app.trustedFunction( function(){ var oMyPolicy = null; app.beginPriv(); // First, Get the ID of My Security Policy var aPols = security.getSecurityPolicies() for(var index=0;index<aPols.length;index++){ if(aPols[index].name == "MySecurityPol"){ oMyPolicy = aPols[index]; break; } } if(oMyPolicy == null){ app.alert("Policy Not Found"); return; } // Now, Apply the security Policy var rtn = this.encryptUsingPolicy({oPolicy: oMyPolicy }); if(rtn.errorCode != 0) app.alert("Security Error: " + rtn.errorText); app.endPriv(); });
I want to put a code in the form field to protect the document, when I click on the form, the code is launched and the document is encrypted.
Copy link to clipboard
Copied
I'm not getting any syntax errors for this code. What is the full text of the error message?
Copy link to clipboard
Copied
Sorry for the absence, it looks like an error if you run the code from the console
if you put the code in the button form field, then the error looks like this
Copy link to clipboard
Copied
Does you select the whole script when you execute it in the console?
You can't define a trusted function in a field button. You must put in a folder level script.