12
Security
Adding Security to PDF Documents
The following example illustrates how to request and display a list of favorite security
policies:
// Set up the filtering options (SecurityOptionsPolicy object):
var options = {
bFavorites: true,
cFilter: "Adobe.PubSec"
};
// Obtain the filtered list of security policies:
var policyArray = security.getSecurityPolicies(options);
// Display the list of security policies by name:
for (var i=0; i<policyArray.length; i++)
console.println(policyArray[i].name);
To encrypt a PDF file using a security policy, you must first choose a security policy by
invoking the
security
object’s
chooseSecurityPolicy
method, and then encrypt
the file by invoking either the
doc
object’s
encryptUsingPolicy
or
encryptForAPS
method.
The
security
object’s
chooseSecurityPolicy
method opens a dialog that permits
the user to choose from a list of security policies, filtered according to a
securityPolicyOptions
object.
The
doc
object’s
encryptUsingPolicy
method accepts three parameters:
●
●
●
cPolicyID
: the policy id to use when encrypting the document
oRecipients
: a
Group
object containing a list of recipients
bIgnoreUnknowns
: determines whether unknown or incomplete recipients will
cause an exception to be thrown
214
Acrobat JavaScript Scripting Guide