PDF Encryption

PDF encryption enables you to securely protect the content of your PDF file from unwanted viewers and against unwanted actions like printing, selecting text, etc.

Following example shows how to convert any workbook to encrypted PDF file with restricted permissions which requires a password to be decrypted, viewed and, optionally, modified.

Password and owner password should be specified in the appropriate text box.

Screenshot of PDF file encrypted with GemBox.Spreadsheet
PDF file encrypted with GemBox.Spreadsheet
Upload your file (Drag file here)
using GemBox.Spreadsheet;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var workbook = ExcelFile.Load("%InputFileName%");

        var password = "%Password%";
        var ownerPassword = "%OwnerPassword%";

        var options = new PdfSaveOptions()
        {
            DocumentOpenPassword = password,
            PermissionsPassword = ownerPassword,
            Permissions = PdfPermissions.None
        };

        workbook.Save("PDF Encryption.pdf", options);
    }
}
Imports GemBox.Spreadsheet

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        Dim workbook = ExcelFile.Load("%InputFileName%")

        Dim password = "%Password%"
        Dim ownerPassword = "%OwnerPassword%"

        Dim options = New PdfSaveOptions() With
        {
            .DocumentOpenPassword = password,
            .PermissionsPassword = ownerPassword,
            .Permissions = PdfPermissions.None
        }

        workbook.Save("PDF Encryption.pdf", options)
    End Sub
End Module

Check next example or download examples from GitHub.