TrySetPrivilege

PdfFileSecurity.TrySetPrivilege method

使用原始密码设置 Pdf 文件安全性。 如果处理失败,则不抛出异常。

public bool TrySetPrivilege(string userPassword, string ownerPassword, DocumentPrivilege privilege)
范围类型描述
userPasswordString原始用户密码。
ownerPasswordString原始所有者密码。
privilegeDocumentPrivilege设置权限。

返回值

真为成功,或为假。

例子

[C#]
string inFile = "D:\\input.pdf"; //TestPath 可能会被重新分配。
string outFile = "D:\\output.pdf"; //TestPath 可能会被重新分配。
PdfFileSecurity fileSecurity = new PdfFileSecurity(inFile,outFile);		
bool result = fileSecurity.TrySetPrivilege(userPassword, ownerPassword, DocumentPrivilege.Print);

[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.TrySetPrivilege(userPassword, ownerPassword, DocumentPrivilege.Print)

也可以看看