Document.Encrypt

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)
ParameterTypeDescription
userPasswordStringUser password.
ownerPasswordStringOwner password.
privilegesDocumentPrivilegeDocument permissions, see Permissions for details.
cryptoAlgorithmCryptoAlgorithmCryptographic algorithm, see CryptoAlgorithm for details.
usePdf20BooleanSupport 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


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)
ParameterTypeDescription
userPasswordStringUser password.
ownerPasswordStringOwner password.
permissionsPermissionsDocument permissions, see Permissions for details.
cryptoAlgorithmCryptoAlgorithmCryptographic algorithm, see CryptoAlgorithm for details.

See Also


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)
ParameterTypeDescription
userPasswordStringUser password.
ownerPasswordStringOwner password.
permissionsPermissionsDocument permissions, see Permissions for details.
cryptoAlgorithmCryptoAlgorithmCryptographic algorithm, see CryptoAlgorithm for details.
usePdf20BooleanSupport for revision 6 (Extension 8).

See Also