PDF for WPF and Silverlight Overview > Features: PDF for WPF and Silverlight > Applying Security and Permissions |
By default, anyone can open, copy, print, and edit PDF files. If your PDF documents contain sensitive information, however, you can encrypt them so that only authorized users can access it.
There is a separate password for the owner of the document and for all other users. The user's access can be selectively restricted to allow only certain operations, such as viewing, printing, or editing the document.
PDF for WPF provides a Security property that returns a PdfSecurity object. This object has properties that allow you to specify the owner password (required to change passwords and permissions for the document) and the user password (required to open the document). Additionally, the PdfSecurity object allows you to specify what permissions a regular user should have. For example you may allow users to see the document but not to print or edit it.
To use the PDF for WPF security features, simply set the passwords before you save the document. For example:
To write the code in Visual Basic:
' Create the document as usual.
CreateDoc()
' Set passwords.
_c1pdf.Security.OwnerPassword = "2mds%dffgd"
_c1pdf.Security.UserPassword = "anyone"
_c1pdf.Security.AllowEditAnnotations = False
_c1pdf.Security.AllowEditContent = False
_c1pdf.Security.AllowPrint = False
To write the code in C#:
// Create the document as usual.
CreateDoc();
// Set passwords.
_c1pdf.Security.OwnerPassword = "2mds%dffgd";
_c1pdf.Security.UserPassword = "anyone";
_c1pdf.Security.AllowEditAnnotations = false;
_c1pdf.Security.AllowEditContent = false;
_c1pdf.Security.AllowPrint = false;