Permissions

Docotic.Pdf Library Help > Samples > Security > Permissions
Docotic.Pdf documentation

This sample shows how to setup user acess permissions for a PDF document.

There are two passwords types: a "user" and an "owner" password. PdfDocument.OwnerPassword property is for an "owner" password and PdfDocument.UserPassword property is for a "user" password.

Opening a PDF document with an "owner" password allows a reader of your document to do everything with opened document. Opening a PDF document with a "user" password allows a reader of your document to only perform operation allowed by user access permissions.

User access permissions may be used to disallow printing of document, filling of form fields or other operations.

C# 
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class Permissions
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToFile = "Permissions.pdf";

            using (PdfDocument pdf = new PdfDocument("Sample data/form.pdf"))
            {
                // an owner password should be set in order to use user access permissions
                pdf.OwnerPassword = "owner";

                pdf.UserPassword = "user";
                pdf.Permissions.Flags = PdfPermissionFlags.None;

                pdf.Save(pathToFile);
            }

            Process.Start(pathToFile);
        }
    }
}
Visual Basic 
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class Permissions
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Dim pathToFile As String = "Permissions.pdf"

            Using pdf As New PdfDocument("Sample data/form.pdf")

                ' an owner password should be set in order to use user access permissions
                pdf.OwnerPassword = "owner"

                pdf.UserPassword = "user"
                pdf.Permissions.Flags = PdfPermissionFlags.None

                pdf.Save(pathToFile)
            End Using

            Process.Start(pathToFile)
        End Sub
    End Class
End Namespace