The Encrypt method secures the PDF document and prevents it from unauthorized access. Two passwords, the owner password and user password, are associated to an encrypted PDF document.
public Function Encrypt(ownerPassword As String, userPassword As String, permissions As uint) As Boolean
public bool Encrypt(string ownerPassword, string userPassword, uint permissions)
ownerPassword
Owner password is the password for the author of the document.
The owner password is optional and allows the author having this password to do any operation he/she wishes on this document, including modifying its security settings. It can be blank, same password as the user, or a password different from the user.
userPassword
User password is the password for the destination or the user of the document.
The user password is optional and can be one of the following:
User Password Option |
Description |
---|---|
A blank password |
The user is not prompted for a password when opening a document, but is restricted to the operations allowed by the author. |
The same password as the owner |
The user is prompted for a password and the author of the document will not be able to open this document as an owner to change its security settings. |
A password different from the owner |
The user will not be able to open the document unless he/she enters a valid password. When a valid password is entered, the document can be viewed but its usage is `restricted to the operations allowed by the author. |
The password dialog can be forced to appear if the SHIFT key is pressed while pressing the open bottom of the "File Open" dialog. This way, the application user can enter the owner password even if the user password is blank.
Permissions
Permissions to user:
Permission Type |
Value (Hex) |
Value (Dec)* |
---|---|---|
No permission. |
0xFFFFFFC0 |
-64 |
Enable Printing (high resolution). |
0xFFFFFFC0 | 0x000004 |
-64 + 4 |
Enable document modification, including document assembly and fill-in existing interactive form fields (including signature fields). |
0xFFFFFFC0 | 0x000008 |
-64 + 8 |
Enable copying text and graphics, and support of accessibility to users with disabilities or for other purposes. |
0xFFFFFFC0 | 0x000010 |
-64 + 16 |
Enable adding and changing notes, and fill-in existing interactive form fields (including signature fields). |
0xFFFFFFC0 | 0x000020 |
-64 + 32 |
(*) NOTE: Converting from HEX DWORD, unsigned and 32-bit unit of data
In the case of the evaluation version, the passwords are always set to "aaaaaa" (Owner Password) and "bbbbbb" (User Password) and cannot be changed.
To combine multiple options, use hexadecimal 0xFFFFF0C0 or decimal -64 plus the values 4, 8, 16 or 32.
E.g. to enable both printing and adding notes, use hexadecimal 0xFFFFFFC0 | 0x000004 | 0x000020, or decimal -64 + 4 + 32 = -28. To disable all 4 options, use hexadecimal 0xFFFFFFC0 or decimal -64.
Member of AmyuniPDFCreator.IacDocument.