Security Plugin

Overview

The Aspose.Pdf.LowCode.Security plugin encrypts and decrypts PDF documents. Use EncryptionOptions for encryption and DecryptionOptions for decryption.

Encrypt a PDF document

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void EncryptPdfWithPlugin()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();

    // Create PDF Security plugin
    var plugin = new Aspose.Pdf.LowCode.Security();

    // Configure encryption options
    var options = new Aspose.Pdf.LowCode.EncryptionOptions(
        "ownerPassword",
        "userPassword",
        Aspose.Pdf.Facades.DocumentPrivilege.ForbidAll,
        Aspose.Pdf.CryptoAlgorithm.AESx256);
    options.AddInput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "Encrypt.pdf"));
    options.AddOutput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "EncryptPdfWithPlugin_out.pdf"));

    // Encrypt the file
    var result = plugin.Process(options);

    // Get the path of the encrypted PDF document
    var outputPath = result.ResultCollection[0].ToFile();
}

Options

EncryptionOptions accepts owner password, user password, DocumentPrivilege, and CryptoAlgorithm.