Click or drag to resize
Pdf Library for .NET

Pdf Security

Select.Pdf can be used to set the basic security settings for the generated pdf files and also manage different permissions:

  • Owner Password

  • User Password

  • Assemble Document permission

  • Copy Content permission

  • Edit Annotations permission

  • Edit Content permission

  • Fill Form Fields permission

  • Print permission

This can be done using Security property of the PdfDocument object.

The strength of the encryption is set with KeySize and Algorithm. The supported combinations are:

A combination that does not exist is adjusted to the nearest one that does: asking for AES with a 40-bit key uses a 128-bit key, and asking for a 256-bit key with RC4 uses AES. The setting that was changed last is kept.

EncryptMetadata set to false leaves the XMP metadata packet readable while the content is encrypted. See Encrypting Regulated Data.

Code Sample
// set document passwords
doc.Security.OwnerPassword = "test1";
doc.Security.UserPassword = "test2";

// set the encryption: AES with a 256-bit key
doc.Security.KeySize = PdfEncryptionKeySize.EncryptKey256Bit;
doc.Security.Algorithm = PdfEncryptionAlgorithm.AES;

//set document permissions
doc.Security.CanAssembleDocument = false;
doc.Security.CanCopyContent = true;
doc.Security.CanEditAnnotations = true;
doc.Security.CanEditContent = true;
doc.Security.CanFillFormFields = true;
doc.Security.CanPrint = true;
See Also