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 UWP provides a C1PdfDocumentBase.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 UWP security features, simply set the passwords before you save the document. For example:
Visual Basic |
Copy Code
|
---|---|
' 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 |
C# |
Copy Code
|
---|---|
// 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; |
Save the document using the Save method as explained in the quick start topic, Step 3 of 4: Saving the document.