Discuss this help topic in SecureBlackbox Forum
Encrypt PDF document using password
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 TElPDFPasswordSecurityHandler class and assign the reference to the created instance to EncryptionHandler property of TElPDFDocument class.
Adjust the properties of TElPDFPasswordSecurityHandler class as needed.
You will need to set passwords and permissions (permissions are described in the corresponding how-to article).
Passwords are set using OwnerPassword
and UserPassword properties.
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.