ComponentOne PDF for .NET
In This Topic
    Security and Permissions
    In This Topic

    Anyone can open, copy, print, and edit PDF files. If your PDF documents contain sensitive information, encrypting them is a good idea so that only the authorized users can access them. PDF security can be maintained with controlling access to PDF documents by encrypting PDF and configuring permission levels that prevents unauthorized users from stealing information in your PDF document.

    For a secured document, usually there is a separate password for the owner of the document and for all other users. One can choose to limit the user's access for just particular actions, such as viewing, printing, or changing the document.

    PDF for .NET provides the ability to specify a password for both the owner and the user through the C1PdfDocumentBase.Security property, which 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. Alternatively, you can choose to specify permissions and only set the owner password, leaving the user password empty. In this case, anyone will be allowed to open the document, but only the owner will be allowed to make any changes or change the permissions.

    To add security in a Pdf document, you simply need to set the passwords before you save the document as showcased in the following code:

    C#
    Copy Code
    // Set passwords.
    pdf.Security.OwnerPassword = "owner";
    pdf.Security.UserPassword = "anyone";
    pdf.Security.AllowEditAnnotations = false;
    pdf.Security.AllowEditContent = false;
    pdf.Security.AllowPrint = false;
    

    Also, note that the encryption scheme used by PDF for .NET is public and is not 100% secure. There are ways to crack encrypted PDF documents. The security provided is adequate to protect your documents from most casual attacks, but if your data is truly sensitive you should not rely on PDF encryption alone.