Click or drag to resize
Pdf Library for .NET

PdfSecurityManager Class

Applies security to an existing PDF document: encryption (passwords, permissions, key size and algorithm) and digital signing with a PFX certificate. Load a document with one of the Load overloads, configure it, then persist with Save(String) / GetDocument.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfSecurityManager

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfSecurityManager

The PdfSecurityManager type exposes the following members.

Constructors
 NameDescription
Public methodPdfSecurityManagerInitializes a new instance of the PdfSecurityManager class.
Top
Properties
 NameDescription
Public propertyCanAccessibilityCopyContentGets or sets whether copying content for accessibility is allowed.
Public propertyCanAssembleDocumentGets or sets whether assembling the document is allowed.
Public propertyCanCopyContentGets or sets whether copying content is allowed.
Public propertyCanEditAnnotationsGets or sets whether editing annotations is allowed.
Public propertyCanEditContentGets or sets whether editing content is allowed.
Public propertyCanFillFieldsGets or sets whether filling form fields is allowed.
Public propertyCanFullQualityPrintGets or sets whether full-quality printing is allowed.
Public propertyCanPrintGets or sets whether printing is allowed.
Public propertyEncryptionAlgorithm Gets or sets the encryption algorithm. Defaults to AES for a document that is not encrypted; an encrypted document keeps its own.
Public propertyEncryptionKeySize Gets or sets the encryption key size. Defaults to EncryptKey256BitRevision6 (AES-256) for a document that is not encrypted; an encrypted document keeps its own.
Public propertyEncryptMetadata Gets or sets whether the document's XMP metadata stream is encrypted with the rest of the document. The default value is true, or what the loaded document already does.
Public propertyOwnerPasswordGets or sets the owner (permissions) password.
Public propertyRevocationCheckEnabled Gets or sets whether ValidateSignatures asks the issuer of each signer's certificate whether it has been revoked, through OCSP or a certificate revocation list. The default value is false.
Public propertyUserPasswordGets or sets the user (open) password.
Top
Methods
 NameDescription
Public methodCloseCloses the loaded document and releases its resources.
Public methodGetDocumentReturns the current state as a new PdfDocument.
Public methodLoad(Byte)Loads a PDF document from a byte array.
Public methodLoad(PdfDocument)Loads an existing PdfDocument.
Public methodLoad(Stream)Loads a PDF document from a stream.
Public methodCode exampleLoad(String)Loads a PDF document from a file.
Public methodLoad(Byte, String)Loads a password-protected PDF document from a byte array.
Public methodLoad(PdfDocument, String)Loads an existing PdfDocument with a password.
Public methodLoad(Stream, String)Loads a password-protected PDF document from a stream.
Public methodLoad(String, String)Loads a password-protected PDF document from a file.
Public methodSaveSaves the document (with the applied security) and returns the bytes.
Public methodSave(Stream)Saves the document (with the applied security) to a stream.
Public methodCode exampleSave(String)Saves the document (with the applied security) to a file.
Public methodCode exampleSign(String, String)Signs the PDF document with the specified PFX certificate.
Public methodSign(String, String, String)Signs the PDF document with the specified PFX certificate.
Public methodSign(String, String, String, String, String, String)Signs the PDF document, recording the reason, location and contact info.
Public methodSign(String, String, String, String, String, String, Int32, RectangleF)Signs the PDF document and places a visible signature on the given page.
Public methodSign(String, String, String, String, String, String, Int32, RectangleF, TimeStampAuthority) Signs the PDF document and, optionally, timestamps it via the specified time-stamp authority.
Public methodValidateSignatures Validates every digital signature of the loaded document, trusting the certificates in the system's trusted store.
Public methodValidateSignatures(PdfDigitalCertificatesCollection) Validates every digital signature of the loaded document, trusting the given certificates as roots - for example your organisation's own certificate authority - in addition to the system's trusted store.
Top
Example
PdfSecurityManager manager = new PdfSecurityManager();
manager.Load("document.pdf");
manager.EncryptionAlgorithm = PdfEncryptionAlgorithm.AES;
manager.EncryptionKeySize = PdfEncryptionKeySize.EncryptKey128Bit;
manager.UserPassword = "open123";
manager.OwnerPassword = "owner456";
manager.CanPrint = true;
manager.Save("encrypted.pdf");
manager.Close();
See Also