Click or drag to resize

PdfSaveOptionsDocumentOpenPassword Property

Specifies the password required for opening the encrypted PDF document.

Namespace:  GemBox.Document
Assembly:  GemBox.Document (in GemBox.Document.dll) Version:
public string DocumentOpenPassword { get; set; }

Property Value

Type: String
The password required for opening the encrypted PDF document.

Generated PDF document will be encrypted if any of the following conditions are satisfied:

  • Permissions is different than All.
  • PermissionsPassword is not or Empty.
  • DocumentOpenPassword is not or Empty.

Both PermissionsPassword and DocumentOpenPassword are optional but with the following consequences:

  • If Permissions is different than All and PermissionsPassword is not specified, component will generate random PermissionsPassword.
  • Using PermissionsPassword, also known as owner password, without DocumentOpenPassword is not secure. It relies on PDF viewer software to respect specified restrictions, but it may choose not to do so.
  • Using DocumentOpenPassword, also known as user password, is potentially very secure. It or PermissionsPassword is required for decrypting and viewing the document.
  • When DocumentOpenPassword is specified, PDF viewer application will prompt for password to decrypt and present the document. If entered password is DocumentOpenPassword, document will be decrypted and presented with specified Permissions enforced. Otherwise, if entered password is PermissionsPassword, document will be decrypted and presented without any restrictions.

DocumentOpenPassword and PermissionsPassword cannot be equal, otherwise exception is thrown.

For more information, see PDF Encryption example.

See Also