PdfEncryption Class
The encryption of a document: by the standard security handler (ISO 32000-2, 7.6.4), with passwords, or by the public-key security handler (7.6.5), for the certificates of recipients. Set PdfDocument.Encryption to encrypt a document when it is saved.
public sealed class PdfEncryptionRemarks
The user password opens the document with the permissions; the owner password opens it with every permission. An empty user password opens the document without a prompt: the permissions are then the only protection, which the readers enforce. A recipient opens the document with the private key of its certificate, with its permissions. A document that is read from an encrypted file keeps its encryption: its PdfDocument.Encryption has no passwords and no recipients, and the document is saved with the keys of the file.
Constructors
| Name | Description |
|---|---|
| PdfEncryption(IEnumerable<PdfEncryptionRecipient>) | Initializes a new instance of the PdfEncryption class that encrypts a document for the certificates of recipients (the public-key security handler, adbe.pkcs7.s5): each opens the document with its private key. |
| PdfEncryption(string, string) | Initializes a new instance of the PdfEncryption class that encrypts a document with passwords. |
PdfEncryption overloads
PdfEncryption(IEnumerable<PdfEncryptionRecipient>)
PdfEncryption.csInitializes a new instance of the PdfEncryption class that encrypts a document for the certificates of recipients (the public-key security handler, adbe.pkcs7.s5): each opens the document with its private key.
public PdfEncryption(params IEnumerable<PdfEncryptionRecipient> recipients)Parameters
recipientsIEnumerable<PdfEncryptionRecipient>- The recipients; at least one.
Exceptions
ArgumentException- There is no recipient, or a recipient is
null.
PdfEncryption(string, string)
PdfEncryption.csInitializes a new instance of the PdfEncryption class that encrypts a document with passwords.
Properties
| Name | Description |
|---|---|
| Algorithm | Gets the algorithm. The default is PdfEncryptionAlgorithm.AesWith256BitKey, which needs PDF 2.0: the version of the file is raised to what the algorithm needs. |
| EncryptMetadata | Gets a value indicating whether the XMP metadata stream is encrypted. The default is true. The RC4 algorithms of the standard security handler always encrypt it. |
| OwnerPassword | Gets the owner password, or null for the encryption of a document read from a file or encrypted for certificates. |
| Permissions | Gets the operations the user password allows, or the recipients whose PdfEncryptionRecipient.Permissions is null. The default is PdfPermissions.All. |
| Recipients | Gets the recipients the document is encrypted for: empty for passwords, and for the encryption of a document read from a file. |
| UserPassword | Gets the user password, or null for the encryption of a document read from a file or encrypted for certificates. |
| UsesCertificates | Gets a value indicating whether the document is encrypted for certificates (the public-key security handler) instead of passwords. |
Algorithm
PdfEncryption.csGets the algorithm. The default is PdfEncryptionAlgorithm.AesWith256BitKey, which needs PDF 2.0: the version of the file is raised to what the algorithm needs.
public PdfEncryptionAlgorithm Algorithm { get; init; }Property value
EncryptMetadata
PdfEncryption.csOwnerPassword
PdfEncryption.csPermissions
PdfEncryption.csGets the operations the user password allows, or the recipients whose PdfEncryptionRecipient.Permissions is null. The default is PdfPermissions.All.
public PdfPermissions Permissions { get; init; }Property value
Recipients
PdfEncryption.csGets the recipients the document is encrypted for: empty for passwords, and for the encryption of a document read from a file.
public IReadOnlyList<PdfEncryptionRecipient> Recipients { get; }