Encrypt

Security and Signatures

Description

This function adds the specified security settings to the selected document.

The actual encryption of the document is delayed until the document is saved so this function can be called at any time, even before further content is added to the document.

Syntax

Delphi

function TPDFlib.Encrypt(Const Owner, User: WideString; Strength, Permissions: Integer): Integer;

ActiveX

Function PDFlib::Encrypt(Owner As String, User As String, Strength As Long, Permissions As Long) As Long

DLL

int DLEncrypt(int InstanceID, wchar_t * Owner, wchar_t * User, int Strength, int Permissions);

Parameters

OwnerThe owner or master password for the document
UserThe user password for the document
StrengthThe strength of encryption to use: 0 = 40-bit encryption 1 = 128-bit RC4 encryption 2 = 128-bit AES encryption (requires Acrobat 7 or later) 3 = 256-bit AES encryption (requires Acrobat 9 or later) 4 = 256-bit AES encryption (requires Acrobat X or later)
PermissionsA value created with the EncodePermissions function

Return values

0The document could not be encrypted. Use the LastErrorCode function to determine the reason for failure. The document was encrypted successfully
1