Document.Encrypt

Encrypt(string, string, DocumentPrivilege, CryptoAlgorithm, bool)

加密文档。然后调用保存以获取文档的加密版本。

public void Encrypt(string userPassword, string ownerPassword, DocumentPrivilege privileges, 
    CryptoAlgorithm cryptoAlgorithm, bool usePdf20)
参数类型描述
userPassword字符串用户密码。
ownerPassword字符串拥有者密码。
privilegesDocumentPrivilege文档权限,详细信息请参见 Permissions
cryptoAlgorithmCryptoAlgorithm加密算法,详细信息请参见 CryptoAlgorithm
usePdf20布尔值支持修订版 6(扩展 8)。

示例

以下示例演示如何使用 DocumentPrivilege 加密 PDF 文件

[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

另请参阅


Encrypt(string, string, Permissions, CryptoAlgorithm)

加密文档。然后调用保存以获取文档的加密版本。

public void Encrypt(string userPassword, string ownerPassword, Permissions permissions, 
    CryptoAlgorithm cryptoAlgorithm)
参数类型描述
userPassword字符串用户密码。
ownerPassword字符串拥有者密码。
permissionsPermissions文档权限,详细信息请参见 Permissions
cryptoAlgorithmCryptoAlgorithm加密算法,详细信息请参见 CryptoAlgorithm

另请参阅


Encrypt(string, string, Permissions, CryptoAlgorithm, bool)

加密文档。然后调用保存以获取文档的加密版本。

public void Encrypt(string userPassword, string ownerPassword, Permissions permissions, 
    CryptoAlgorithm cryptoAlgorithm, bool usePdf20)
参数类型描述
userPassword字符串用户密码。
ownerPassword字符串拥有者密码。
permissionsPermissions文档权限,详细信息请参见 Permissions
cryptoAlgorithmCryptoAlgorithm加密算法,详细信息请参见 CryptoAlgorithm
usePdf20布尔值支持修订版 6(扩展 8)。

另请参阅