Pdf | |
The PdfDocumentSecurity type exposes the following members.
| Name | Description | |
|---|---|---|
| Algorithm | Gets or sets the encryption algorithm. Defaults to AES for a new document and for a loaded document that is not encrypted. Setting a value that is incompatible with the current KeySize silently adjusts the key size to a supported one (AES + 40-bit → 128-bit; AES-GCM → 256-bit; RC4 + 256-bit → 128-bit). | |
| CanAccessibilityCopyContent | Gets or sets a value indicating whether content can be copied for accessibility purposes. | |
| CanAssembleDocument | Gets or sets a value indicating whether the document can be assembled (insert, rotate, or delete pages and create bookmarks or thumbnails). | |
| CanCopyContent | Gets or sets a value indicating whether the document content can be copied. | |
| CanEditAnnotations | Gets or sets a value indicating whether annotations can be edited. | |
| CanEditContent | Gets or sets a value indicating whether the document content can be edited. | |
| CanFillFormFields | Gets or sets a value indicating whether form fields can be filled. | |
| CanPrint | Gets or sets a value indicating whether the document can be printed. | |
| EncryptMetadata | Gets or sets whether the document's XMP metadata stream is encrypted with the rest of the document. The default value is true. | |
| KeySize | Gets or sets the length of the encryption key. Defaults to EncryptKey256BitRevision6 (AES-256) for a new document and for a loaded document that is not encrypted; an encrypted document keeps its own. Setting a value that is incompatible with the current Algorithm silently adjusts the algorithm to a supported one (40-bit → RC4; 256-bit + RC4 → AES; 256-bit revision 6 → AES). Valid combinations: 40/128-bit + RC4, 128/256-bit + AES, 256-bit revision 6 + AES (PDF 2.0), 256-bit + AES-GCM (PDF 2.0). | |
| OwnerPassword | Gets or sets the owner password required to change document permissions. | |
| UserPassword | Gets or sets the user password required to open the document. |
PdfDocument document = new PdfDocument(); document.AddPage(); document.Security.UserPassword = "open123"; document.Security.OwnerPassword = "owner456"; document.Security.Algorithm = PdfEncryptionAlgorithm.AES; document.Security.CanPrint = true; document.Security.CanCopyContent = false; document.Save("secured.pdf"); document.Close();