GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfPasswordEncryption Class

    Namespace:
    GemBox.Pdf.Security
    Assembly:
    GemBox.Pdf.dll

    Stores encryption-related information for a PDF's standard security handler that shall allow up to two passwords to be specified for a document: a DocumentOpenPassword and a PermissionsPassword with access Permissions.

    • C#
    • VB.NET
    public sealed class PdfPasswordEncryption : PdfEncryption
    Public NotInheritable Class PdfPasswordEncryption
        Inherits PdfEncryption
    Inheritance:
    System.Object
    PdfObject
    PdfEncryption
    PdfPasswordEncryption

    Properties

    DocumentOpenPassword

    Gets or sets the Document Open password (also known as a user password) required to open the PDF file.

    Default value: System.String.Empty (PDF file can be decrypted without a password).

    • C#
    • VB.NET
    public string DocumentOpenPassword { get; set; }
    Public Property DocumentOpenPassword As String
    Property Value
    System.String

    The Document Open password.

    Exceptions
    System.InvalidOperationException

    Current encryption information is used to read or write an encrypted PDF file and cannot be changed. Set new encryption information instead.

    EncryptionLevel

    Gets or sets the encryption level.

    Default value: AES_128.

    • C#
    • VB.NET
    public PdfEncryptionLevel EncryptionLevel { get; set; }
    Public Property EncryptionLevel As PdfEncryptionLevel
    Property Value
    PdfEncryptionLevel

    The encryption level.

    Exceptions
    System.ArgumentException

    Value is not RC4_40, RC4_128, AES_128 nor AES_256.

    System.InvalidOperationException

    Current encryption information is used to read or write an encrypted PDF file and cannot be changed. Set new encryption information instead.

    Options

    Gets or sets the encryption options.

    Default value: EncryptAll.

    • C#
    • VB.NET
    public PdfEncryptionOptions Options { get; set; }
    Public Property Options As PdfEncryptionOptions
    Property Value
    PdfEncryptionOptions

    The encryption options.

    Exceptions
    System.InvalidOperationException

    Current encryption information is used to read or write an encrypted PDF file and cannot be changed. Set new encryption information instead.

    Permissions

    (Required) A set of flags specifying which operations shall be permitted when the document is opened with user access (see Table 22).

    • C#
    • VB.NET
    public PdfUserAccessPermissions Permissions { get; set; }
    Public Property Permissions As PdfUserAccessPermissions
    Property Value
    PdfUserAccessPermissions

    A set of flags specifying which operations shall be permitted when the document is opened with user access.

    Exceptions
    System.InvalidOperationException

    Current encryption information is used to read or write an encrypted PDF file and cannot be changed. Set new encryption information instead.

    See Also
    PDF Specification ISO 32000-1:2008, section '7.6.3.2 Standard Encryption Dictionary'

    PermissionsPassword

    Gets or sets the Permissions password (also known as a master password) required if a user performs an action that is not allowed by Permissions.

    Default value: DocumentOpenPassword (actions not allowed by Permissions can be performed without a password).

    • C#
    • VB.NET
    public string PermissionsPassword { get; set; }
    Public Property PermissionsPassword As String
    Property Value
    System.String

    The Permissions password.

    Exceptions
    System.InvalidOperationException

    Current encryption information is used to read or write an encrypted PDF file and cannot be changed. Set new encryption information instead.

    Methods

    CheckPassword(String, PdfDocument, out Boolean)

    Determines whether the specified password is correct password to decrypt the specified document using this PdfPasswordEncryption.

    • C#
    • VB.NET
    public bool CheckPassword(string password, PdfDocument document, out bool isPermissionsPassword)
    Public Function CheckPassword(password As String, document As PdfDocument, ByRef isPermissionsPassword As Boolean) As Boolean
    Parameters
    password
    System.String

    The password to check for correctness.

    document
    PdfDocument

    The encrypted document for which to check the specified password.

    isPermissionsPassword
    System.Boolean

    If set to true, the specified password is a correct PermissionsPassword.

    Returns
    System.Boolean

    true if the specified password is a correct password to decrypt the specified document using this PdfPasswordEncryption; otherwise, false.

    Exceptions
    System.ArgumentNullException

    password or document is null.

    Inherited Properties

    Metadata

    (Optional; PDF 1.4) A metadata stream containing metadata for the component.

    (Inherited from PdfObject)

    Extension Methods

    PdfObjectExtensions.GetDictionary(PdfObject)
    PdfObjectExtensions.GetOrAddDictionary(PdfObject)
    PdfObjectExtensions.GetArray(PdfObject)

    Examples

    Encryption examples
    Encryption settings example
    Restrict editing example

    See Also

    PDF Specification ISO 32000-1:2008, section '7.6.3 Standard Security Handler'
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.