Skip to main content
All docs
V25.1
  • EncryptionOptions Class

    Contains members used to specify encryption options of an exported PDF file.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Core.v25.1.dll

    NuGet Package: DevExpress.Docs.Core

    Declaration

    public class EncryptionOptions

    The following members return EncryptionOptions objects:

    Remarks

    The EncryptionOptions property allows you to obtain the security options of the exported PDF file.

    User and Owner Passwords

    The UserPassword property allows you to specify the user password. This password is used when you want to prevent unauthorized access to a document. This password protects sensitive information.

    The OwnerPassword specifies the permission (or owner) password used to restrict operations in the PDF document.

    Note

    If the Owner and User passwords are the same or the Owner password is missing and the document is protected only with the User password, the resulting document has a document opening restriction. In this case, any user has full access to this document after opening it.

    Restrict Document Operations

    Use the following options to restrict data extraction, data modification, interactive, or printing operations:

    Specify the EncryptionOptions.OwnerPassword property to apply restrictions. Users will need to enter the owner password when opening a document to gain full access to its operations.

    Example

    The following code snippet specifies available encryption settings:

    using DevExpress.Docs.Pdf;
    using DevExpress.Docs.Presentation;
    using DevExpress.Docs.Presentation.Export;
    
    using (var presentation = new Presentation(File.ReadAllBytes(@"C:\Documents\Presentation.pptx")))
    {
        var options = new PdfExportOptions();
        // Specify operation restrictions:
        options.EncryptionOptions.DataExtractionPermissions =
            DocumentDataExtractionPermissions.NotAllowed;
        options.EncryptionOptions.PrintPermissions =
            DocumentPrintPermissions.LowQuality;
        options.EncryptionOptions.ModificationPermissions = DocumentModificationPermissions.NotAllowed;
    
        // Set user and owner passwords:
        options.EncryptionOptions.UserPassword = "userPassword";
        options.EncryptionOptions.OwnerPassword = "ownerPassword";
    
        // Specify encryption algorithm:
        options.EncryptionOptions.Algorithm = EncryptionAlgorithm.AES256;
    
        presentation.ExportToPdf(new FileStream("C:\\Documents\\Presentation.pdf", FileMode.Create, FileAccess.ReadWrite), options);
    }
    

    Inheritance

    Object
    EncryptionOptions
    See Also