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)

1using GemBox.Spreadsheet;
2using System.IO;
3
4class Sample
5{
6    [STAThread]
7    static void Main(string[] args)
8    {
9        // If using Professional version, put your serial key below.
10        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
11
12        ExcelFile ef = ExcelFile.Load("SimpleTemplate.xlsx");
13
14        string password = "pass";
15        string ownerPassword = "";
16
17        var options = new PdfSaveOptions()
18        {
19            DocumentOpenPassword = password,
20            PermissionsPassword = ownerPassword,
21            Permissions = PdfPermissions.None
22        };
23
24        ef.Save("PDF Encryption.pdf", options);
25    }
26}
1Imports GemBox.Spreadsheet
2Imports System.IO
3
4Module Samples
5
6    Sub Main()
7
8        ' If using Professional version, put your serial key below.
9        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
10
11        Dim ef As ExcelFile = ExcelFile.Load("SimpleTemplate.xlsx")
12
13        Dim password As String = "pass"
14        Dim ownerPassword As String = ""
15
16        Dim options = New PdfSaveOptions() With
17        {
18            .DocumentOpenPassword = password,
19            .PermissionsPassword = ownerPassword,
20            .Permissions = PdfPermissions.None
21        }
22
23        ef.Save("PDF Encryption.pdf", options)
24
25    End Sub
26
27End Module

Check next sample or find out more about GemBox.Spreadsheet and GemBox Software.