Discuss this help topic in SecureBlackbox Forum

Encrypt the document using X.509 certificate

First load the document as described in the corresponding how-to article.

Ensure, that the document is not already encrypted by checking the value of Encrypted property of TElPDFDocument class.

Next, create an instance of TElPDFPublicKeySecurityHandler class and assign the reference to the created instance to EncryptionHandler property of TElPDFDocument class.

To specify certificates, used for encryption, take the following steps:

  1. Create the recipient group by calling AddRecipientGroup() method of TElPDFPublicKeySecurityHandler class. The method returns the index of the added group.
  2. Load or otherwise obtain the certificate that you need to use for encryption. You can use multiple certificates, and the owner of each certificate will be able to decrypt the document.
  3. Access the newly added group by reading the value of RecipientGroups[] property of TElPDFPublicKeySecurityHandler class. The returned value is of TElPDFPublicKeyRecipientGroup type.
  4. Call AddRecipient() of TElPDFPublicKeyRecipientGroup class and pass the certificate to this method. Call the method several times to add several certificates.
  5. Set permissions of the group (permissions are described in the corresponding how-to article).

Also you need to set encryption parameters using StreamEncryptionAlgorithm, StreamEncryptionKeyBits, StringEncryptionAlgorithm, StringEncryptionKeyBits properties of TElPDFSecurityHandler class. First two properties specify encryption parameters for binary data, while the last one specify parameters for string encryption.
You can specify whether metadata should be encrypted by setting the appropriate value to EncryptMetadata property of TElPDFSecurityHandler class.

Call Encrypt() method of TElPDFDocument to perform encryption.

Save and close the document using Close() method.

How To articles about PDF encryption

Discuss this help topic in SecureBlackbox Forum