Click or drag to resize
Pdf Library for .NET

Pdf Security Settings

Select.Pdf can be used to set the basic security settings for the generated pdf files and also manage different permissions:

  • Owner Password

  • User Password

  • Assemble Document permission

  • Copy Content permission

  • Edit Annotations permission

  • Edit Content permission

  • Fill Form Fields permission

  • Print permission

When the pdf document is generated as a result of an html to pdf conversion, these properties can be set using SecurityOptions property of the HtmlToPdfOptions object.

Code Sample

This sample code shows how to convert from html to pdf using Select.Pdf, how to set a password to be able to view or modify the document and also specify user permissions for the pdf document (if the user can print, copy content, fill forms, modify, etc).

// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();

// set document passwords
converter.Options.SecurityOptions.OwnerPassword = "test1";
converter.Options.SecurityOptions.UserPassword = "test2";

//set document permissions
converter.Options.SecurityOptions.CanAssembleDocument = false;
converter.Options.SecurityOptions.CanCopyContent = true;
converter.Options.SecurityOptions.CanEditAnnotations = true;
converter.Options.SecurityOptions.CanEditContent = true;
converter.Options.SecurityOptions.CanFillFormFields = true;
converter.Options.SecurityOptions.CanPrint = true;

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(url);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
See Also