# Support Security Options

DsExcel allows you to restrict the PDF’s access to unauthorized users while saving Excel spreadsheets to PDF files by passwords, print permission, etc.

## Content

Sometimes, users need to secure their digital documents with user/owner passwords, print permission, content permission, annotation permission etc. PDF documents have always been the preferred format for sharing digital files among professionals. The DsExcel library supports Security Options while saving Excel spreadsheets to PDF files. It helps in securing a PDF Document by restricting the PDF’s access to unauthorized users as per the options specified.
With DsExcel's [PdfSecurityOptions](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.html) class, you can restrict access to your PDF document, while converting Excel spreadsheet to PDF document. You can choose through the following security properties in the **PdfSecurityOptions** class:

| **Properties** | **Description** |
| ---------- | ----------- |
| [UserPassword](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.UserPassword.html) | Gets or sets the user password of the PDF document. |
| [OwnerPassword](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.OwnerPassword.html) | Gets or sets the owner password of the PDF document. This password is required to change the permissions for the PDF document. |
| [PrintPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.PrintPermission.html) | Gets or sets the permission to print the PDF document. The default value is true for this property. |
| [FullQualityPrintPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.FullQualityPrintPermission.html) | Gets or sets the permission to print in high quality. The default value is true for this property, and it only works when **PrintPermission** property is set to true. |
| [ExtractContentPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.ExtractContentPermission.html) | Gets or sets the permission to copy or extract content. The default value is true for this property. |
| [ModifyDocumentPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.ModifyDocumentPermission.html) | Gets or sets the permission to modify the PDF document. The default value is true for this property. |
| [AssembleDocumentPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.AssembleDocumentPermission.html) | Gets or sets the permission to insert, rotate or delete pages, and create bookmarks/thumbnail images. The default value is true for this property. If you want to prevent a user from inserting, rotating or deleting pages, you need to set **ModifyDocumentPermission** property to false as well. |
| [ModifyAnnotationsPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.ModifyAnnotationsPermission.html) | Gets or sets the permission to modify text annotations and fill the form fields. The default value is true for this property. |
| [FillFormsPermission](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.PdfSecurityOptions.FillFormsPermission.html) | Gets or sets the permission to fill the form fields even if the **ModifyAnnotationsPermission** property returns false. The default value for this property is true. Note that if you want to prevent a user from filling interactive form fields, you need to set the **ModifyAnnotationsPermission** property to false. |

## Using Code

Refer to the following example to add security options while exporting Excel spreadsheets to PDF documents.

```csharp
public void SavePDFPdfSecurityOptions()
{
    // Initialize workbook
    Workbook workbook = new Workbook();
    // Fetch default worksheet 
    IWorksheet worksheet = workbook.Worksheets[0];
    // Data
    object[,] data = new object[,]{
 {"Name", "City", "Birthday", "Sex", "Weight", "Height", "Age"},
 {"Bob", "NewYork", new DateTime(1968, 6, 8), "male", 80, 180, 56},
 {"Betty", "NewYork", new DateTime(1972, 7, 3), "female", 72, 168, 45},
 {"Gary", "NewYork", new DateTime(1964, 3, 2), "male", 71, 179, 50},
 {"Hunk", "Washington", new DateTime(1972, 8, 8), "male", 80, 171, 59},
 {"Cherry", "Washington", new DateTime(1986, 2, 2), "female", 58, 161, 34},
 {"Coco", "Virginia", new DateTime(1982, 12, 12), "female", 58, 181, 45},
 {"Lance", "Chicago", new DateTime(1962, 3, 12), "female", 49, 160, 57},
 { "Eva", "Washington", new DateTime(1993, 2, 5), "female", 71, 180, 81}};
    // Set data
    worksheet.Range["A1:G9"].Value = data;

    //The security settings of pdf when converting excel to pdf
    PdfSecurityOptions securityOptions = new PdfSecurityOptions();
    //Sets the user password
    securityOptions.UserPassword = "user";
    //Sets the owner password
    securityOptions.OwnerPassword = "owner";
    //Printing the pdf document is not allowed
    securityOptions.PrintPermission = false;
    //Filling the form fields of the pdf document is not allowed
    securityOptions.FillFormsPermission = false;

    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
    //Sets the security settings of the pdf
    pdfSaveOptions.SecurityOptions = securityOptions;

    // Saving workbook to PDF
    workbook.Save(@"4-SavePDFPdfSecurityOptions.pdf", pdfSaveOptions);
}
```

> !type=note
> **Note:** DsExcel uses RC4 encryption with key from 40 to 128 bit length and allows to define additional permission flags.