// Create a pdf file stream using FileStream outputStream = new FileStream("SetSecurityOptionsToPDF.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1"].Value = "Document Solutions for Excel"; worksheet.Range["A1"].Font.Size = 25; //The security settings of pdf when converting excel to pdf. PdfSecurityOptions securityOptions = new PdfSecurityOptions { //Sets the user password. UserPassword = "user", //Sets the owner password. OwnerPassword = "owner", //Allow to print pdf document. PrintPermission = true, //Print the pdf document in high quality. FullQualityPrintPermission = true, //Allow to copy or extract the content of the pdf document. ExtractContentPermission = true, //Allow to modify the pdf document. ModifyDocumentPermission = true, //Allow to insert, rotate, or delete pages and create bookmarks or thumbnail images of the pdf document. AssembleDocumentPermission = true, //Allow to modify text annotations and fill the form fields of the pdf document. ModifyAnnotationsPermission = true, //Filling the form fields of the pdf document is not allowed. FillFormsPermission = false }; PdfSaveOptions pdfSaveOptions = new PdfSaveOptions { //Sets the secutity settings of the pdf. SecurityOptions = securityOptions }; //Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions);
' Create a pdf file stream Dim outputStream = File.Create("SetSecurityOptionsToPDF.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range!A1.Value = "Document Solutions for Excel" worksheet.Range!A1.Font.Size = 25 'The security settings of pdf when converting excel to pdf. Dim securityOptions As New PdfSecurityOptions With securityOptions 'Sets the user password. .UserPassword = "user" 'Sets the owner password. .OwnerPassword = "owner" 'Allow to print pdf document. .PrintPermission = True 'Print the pdf document in high quality. .FullQualityPrintPermission = True 'Allow to copy or extract the content of the pdf document. .ExtractContentPermission = True 'Allow to modify the pdf document. .ModifyDocumentPermission = True 'Allow to insert, rotate, or delete pages and create bookmarks or thumbnail images of the pdf document. .AssembleDocumentPermission = True 'Allow to modify text annotations and fill the form fields of the pdf document. .ModifyAnnotationsPermission = True 'Filling the form fields of the pdf document is not allowed. .FillFormsPermission = False End With 'Sets the secutity settings of the pdf. Dim pdfSaveOptions As New PdfSaveOptions With { .SecurityOptions = securityOptions } 'Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions)