Document.Encrypt
Contents
[
Hide
]Encrypt(string, string, DocumentPrivilege, CryptoAlgorithm, bool)
Encrypts the document. Call then Save to get encrypted version of the document.
public void Encrypt(string userPassword, string ownerPassword, DocumentPrivilege privileges,
CryptoAlgorithm cryptoAlgorithm, bool usePdf20)
Parameter | Type | Description |
---|---|---|
userPassword | String | User password. |
ownerPassword | String | Owner password. |
privileges | DocumentPrivilege | Document permissions, see Permissions for details. |
cryptoAlgorithm | CryptoAlgorithm | Cryptographic algorithm, see CryptoAlgorithm for details. |
usePdf20 | Boolean | Support for revision 6 (Extension 8). |
Examples
The following example shows how to encrypt PDF files with DocumentPrivilege
[C#]
// The path to your PDF File.
string pdfFilePath = "YOUR_PDF_FILE_PATH";
// Open document
using (Document document = new Document(pdfFilePath))
{
// Encrypt PDF
document.Encrypt("YOUR_USER_PASSWORD", "YOUR_OWNER_PASSWORD", DocumentPrivilege.AllowAll, CryptoAlgorithm.RC4x128, true);
// Save updated PDF
document.Save(pdfFilePath);
}
[VB.NET]
' The path to your PDF File.
Dim pdfFilePath As String = "YOUR_PDF_FILE_PATH"
' Open document
Using document As Document = New Document(pdfFilePath)
' Encrypt PDF
document.Encrypt("YOUR_USER_PASSWORD", "YOUR_OWNER_PASSWORD", DocumentPrivilege.AllowAll, CryptoAlgorithm.RC4x128, True)
' Save updated PDF
document.Save(pdfFilePath)
End Using
See Also
- class DocumentPrivilege
- enum CryptoAlgorithm
- class Document
- namespace Aspose.Pdf
- assembly Aspose.PDF
Encrypt(string, string, Permissions, CryptoAlgorithm)
Encrypts the document. Call then Save to get encrypted version of the document.
public void Encrypt(string userPassword, string ownerPassword, Permissions permissions,
CryptoAlgorithm cryptoAlgorithm)
Parameter | Type | Description |
---|---|---|
userPassword | String | User password. |
ownerPassword | String | Owner password. |
permissions | Permissions | Document permissions, see Permissions for details. |
cryptoAlgorithm | CryptoAlgorithm | Cryptographic algorithm, see CryptoAlgorithm for details. |
See Also
- enum Permissions
- enum CryptoAlgorithm
- class Document
- namespace Aspose.Pdf
- assembly Aspose.PDF
Encrypt(string, string, Permissions, CryptoAlgorithm, bool)
Encrypts the document. Call then Save to get encrypted version of the document.
public void Encrypt(string userPassword, string ownerPassword, Permissions permissions,
CryptoAlgorithm cryptoAlgorithm, bool usePdf20)
Parameter | Type | Description |
---|---|---|
userPassword | String | User password. |
ownerPassword | String | Owner password. |
permissions | Permissions | Document permissions, see Permissions for details. |
cryptoAlgorithm | CryptoAlgorithm | Cryptographic algorithm, see CryptoAlgorithm for details. |
usePdf20 | Boolean | Support for revision 6 (Extension 8). |
See Also
- enum Permissions
- enum CryptoAlgorithm
- class Document
- namespace Aspose.Pdf
- assembly Aspose.PDF