Click or drag to resize
Pdf Library for .NET

Advanced Security Settings

SelectPdf can be used to set advanced security settings on existing pdf files, manage different permissions and digitally sign the documents.

This can be done using PdfSecurityManager object. Using it, the following settings can be customized:

  • Owner Password

  • User Password

  • Encryption Algorithm (RC4 or AES)

  • Encryption Key Length (40, 128 or 256 bits)

  • Assemble Document permission

  • Copy Content permission

  • Edit Annotations permission

  • Edit Content permission

  • Fill Form Fields permission

  • Print permission (including Full Quality Print)

Digital signatures can be added to an existing PDF document using the PdfSecurityManager object. Adding a digital signature requires a PKCS#12 certificate (provided as a .pfx file).

Code Sample
// load the pdf document using the advanced security manager
PdfSecurityManager security = new PdfSecurityManager();
security.Load(file);

// encryption algorithm and key length
security.EncryptionAlgorithm = PdfEncryptionAlgorithm.AES;
security.EncryptionKeySize = PdfEncryptionKeySize.EncryptKey256Bit;

// set document passwords
security.OwnerPassword = "test1";
security.UserPassword = "test2";

//set document permissions
security.CanAssembleDocument = false;
security.CanCopyContent = true;
security.CanEditAnnotations = true;
security.CanEditContent = true;
security.CanFillFields = true;
security.CanPrint = true;

// add the digital signature
security.Sign(certFile, "password");

// save pdf document
security.Save("Sample.pdf");

// close pdf document
security.Close();
See Also