Products
PDFKit.NET 4.0
Created
12/4/2015
Tags
Security

In this tutorial we will have a look at the adobe reader security settings, and how you can change them using your PDFKit application

When you have a look at the security settings of a PDF using Adobe Reader (file -> properties -> security), you will get a screen similar to the following:

Now how can we change these fields, so Adobe Reader knows what restrictions to enforce on the PDF document? We can change this by creating a PasswordSecurity object in PDFKit, applying the desired settings to it and writing the PDF document to disk with the new security settings. Note that currently PasswordSecurity is the only concrete implementation of the abstract Security class. Although its purpose is to add password security to PDFs, this is not necessary if you keep the password fields empty.

C# code sample PasswordSecurity ps = new PasswordSecurity(); ps.AuthorCommentsFormFields = false; //links to commenting; ps.Change = true; //link to template creation ps.CopyExtract = false; //links to content copying ps.ExtractAccessibilityContents = false; //accessibility only when copyextract = false ps.Assembly = false; //no link ps.FormFillSign = false; //only links to filling of form fields/signing if AuthorCommentsFormFields = false and change=false; ps.Print = false; //links to printing ps.PrintHighQuality = false; //no link d.Security = ps; using (FileStream output = new FileStream("../../output.pdf", FileMode.Create, FileAccess.Write)) { d.Write(output); }

} ]]>

Note that the fields do not in general link to the Adobe Reader fields one-to-one as you would expect. Some fields are only meaningful if other fields are also inactive (please refer to the documentation). To give a clear overview on how you can directly change the Adobe Reader fields, here is a list of the fields:

  • Printing: is allowed, unless ps.Print is set to false.
  • Document Assembly: is never allowed, regardless of the password security settings.
  • Content Copying: is allowed, unless ps.CopyExtract is set to false.
  • Content Copying for Accessibility: is allowed, unless ps.ExtractAccessibilityContents and ps.CopyExtract is set to false.
  • Page Extraction: is never allowed, regardless of the password security settings.
  • Commenting: is allowed, unless ps.AuthorCommentsFormFields is set to false.
  • Filling of Form Fields: is allowed, unless ps.FormFillSign, ps.AuthorCommentsFormFields and ps.Change are set to false.
  • Signing: is allowed, unless ps.FormFillSign, ps.AuthorCommentsFormFields and ps.Change are set to false.
  • Creation of Template Pages: is allowed, unless ps.CopyExtract is set to false

Note that some fields do not influence the adobe security settings at all, and some fields only indirectly.