TryEncryptFile
PdfFileSecurity.TryEncryptFile method
使用userpassword 和ownerpassword 加密Pdf 文件,并设置文档的访问权限。 用户密码和所有者密码可以为空或空。如果输入的所有者密码为空或为空,所有者密码将被替换为随机字符串 。 如果处理失败不抛出异常。
public bool TryEncryptFile(string userPassword, string ownerPassword, DocumentPrivilege privilege,
KeySize keySize)
范围 | 类型 | 描述 |
---|---|---|
userPassword | String | 用户密码。 |
ownerPassword | String | 所有者密码。 |
privilege | DocumentPrivilege | 设置权限。 |
keySize | KeySize | KeySize.x40 用于 40 位加密,KeySize.x128 用于 128 位加密, KeySize.x256 用于 256 位加密。 |
返回值
真为成功,或为假。
例子
[C#]
string inFile = "D:\\input.pdf"; //TestPath 可能会被重新分配。
string outFile = "D:\\output.pdf"; //TestPath 可能会被重新分配。
PdfFileSecurity fileSecurity = new PdfFileSecurity(inFile,outFile);
bool result = fileSecurity.TryEncryptFile("userpass", "ownerpass", DocumentPrivilege.Print, KeySize.x256);
[Visual Basic]
Dim inFile As String = "D:\\input.pdf" 'The TestPath may be re-assigned.'
Dim outFile As String = "D:\\output.pdf" 'The TestPath may be re-assigned.'
Dim fileSecurity As PdfFileSecurity = New PdfFileSecurity(inFile,outFile)
Dim result As Boolean = fileSecurity.TryEncryptFile("userpass", "ownerpass", DocumentPrivilege.Print, KeySize.x256)
也可以看看
- class DocumentPrivilege
- enum KeySize
- class PdfFileSecurity
- 命名空间 Aspose.Pdf.Facades
- 部件 Aspose.PDF