GemBox.Spreadsheet is a .NET component that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.

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
PDF Encryption Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using GemBox.Spreadsheet;
using System.IO;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        ExcelFile ef = ExcelFile.Load("SimpleTemplate.xlsx");

        string password = "pass";
        string ownerPassword = "";

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

        ef.Save("PDF Encryption.pdf", options);
    }
}
Imports GemBox.Spreadsheet
Imports System.IO

Module Samples

    Sub Main()

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

        Dim ef As ExcelFile = ExcelFile.Load("SimpleTemplate.xlsx")

        Dim password As String = "pass"
        Dim ownerPassword As String = ""

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

        ef.Save("PDF Encryption.pdf", options)

    End Sub

End Module

Check next sample.