 |
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 HierarchySystemObject
SelectPdf.UniversalPdfSecurityManager
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntaxpublic class PdfSecurityManager
Public Class PdfSecurityManager
The PdfSecurityManager type exposes the following members.
Constructors
Properties| | Name | Description |
|---|
 | CanAccessibilityCopyContent | Gets or sets whether copying content for accessibility is allowed. |
 | CanAssembleDocument | Gets or sets whether assembling the document is allowed. |
 | CanCopyContent | Gets or sets whether copying content is allowed. |
 | CanEditAnnotations | Gets or sets whether editing annotations is allowed. |
 | CanEditContent | Gets or sets whether editing content is allowed. |
 | CanFillFields | Gets or sets whether filling form fields is allowed. |
 | CanFullQualityPrint | Gets or sets whether full-quality printing is allowed. |
 | CanPrint | Gets or sets whether printing is allowed. |
 | EncryptionAlgorithm |
Gets or sets the encryption algorithm. Defaults to AES for a
document that is not encrypted; an encrypted document keeps its own.
|
 | EncryptionKeySize |
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.
|
 | EncryptMetadata |
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.
|
 | OwnerPassword | Gets or sets the owner (permissions) password. |
 | RevocationCheckEnabled |
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.
|
 | UserPassword | Gets or sets the user (open) password. |
Top
Methods| | Name | Description |
|---|
 | Close | Closes the loaded document and releases its resources. |
 | GetDocument | Returns the current state as a new PdfDocument. |
 | Load(Byte) | Loads a PDF document from a byte array. |
 | Load(PdfDocument) | Loads an existing PdfDocument. |
 | Load(Stream) | Loads a PDF document from a stream. |
  | Load(String) | Loads a PDF document from a file. |
 | Load(Byte, String) | Loads a password-protected PDF document from a byte array. |
 | Load(PdfDocument, String) | Loads an existing PdfDocument with a password. |
 | Load(Stream, String) | Loads a password-protected PDF document from a stream. |
 | Load(String, String) | Loads a password-protected PDF document from a file. |
 | Save | Saves the document (with the applied security) and returns the bytes. |
 | Save(Stream) | Saves the document (with the applied security) to a stream. |
  | Save(String) | Saves the document (with the applied security) to a file. |
  | Sign(String, String) | Signs the PDF document with the specified PFX certificate. |
 | Sign(String, String, String) | Signs the PDF document with the specified PFX certificate. |
 | Sign(String, String, String, String, String, String) | Signs the PDF document, recording the reason, location and contact info. |
 | Sign(String, String, String, String, String, String, Int32, RectangleF) | Signs the PDF document and places a visible signature on the given page. |
 | Sign(String, String, String, String, String, String, Int32, RectangleF, TimeStampAuthority) |
Signs the PDF document and, optionally, timestamps it via the specified time-stamp authority.
|
 | ValidateSignatures |
Validates every digital signature of the loaded document, trusting the certificates in the system's
trusted store.
|
 | ValidateSignatures(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
ExamplePdfSecurityManager 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();Dim manager As 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