PdfFileSecurity.ChangePassword

ChangePassword(string, string, string)

通过所有者密码更改用户密码和所有者密码,同时保持原始安全设置。新用户密码和新所有者密码可以为 null 或空。如果新所有者密码为 null 或空,则所有者密码将被随机字符串替换。如果处理失败,则抛出异常。

public bool ChangePassword(string ownerPassword, string newUserPassword, string newOwnerPassword)
参数类型描述
ownerPassword字符串原始所有者密码。
newUserPassword字符串新用户密码。
newOwnerPassword字符串新所有者密码。

返回值

成功返回 true。

示例

[C#]
 string inFile = "D:\\input.pdf"; //The TestPath may be re-assigned.
 string outFile = "D:\\output.pdf";	//The TestPath may be re-assigned.
 PdfFileSecurity fileSecurity = new PdfFileSecurity(inFile,outFile);		
 fileSecurity.ChangePassword("owner","newuser","newowner");

[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) 
 fileSecurity.ChangePassword("owner","newuser","newowner")	

另请参阅


ChangePassword(string, string, string, DocumentPrivilege, KeySize)

通过所有者密码更改用户密码和密码,允许重置 Pdf 文档安全性。新用户密码和新所有者密码可以为 null 或空。如果新所有者密码为 null 或空,则所有者密码将被随机字符串替换。如果处理失败,则抛出异常。

public bool ChangePassword(string ownerPassword, string newUserPassword, string newOwnerPassword, 
    DocumentPrivilege privilege, KeySize keySize)
参数类型描述
ownerPassword字符串原始所有者密码。
newUserPassword字符串新用户密码。
newOwnerPassword字符串新所有者密码。
privilegeDocumentPrivilege重置安全性。
keySizeKeySizeKeySize.x40 表示 40 位加密,KeySize.x128 表示 128 位加密,KeySize.x256 表示 256 位加密。

返回值

成功返回 true。

示例

[C#]
string inFile = ".D:\\input.pdf"; //The TestPath may be re-assigned.
string outFile = "D:\\output.pdf";	//The TestPath may be re-assigned.
PdfFileSecurity fileSecurity = new PdfFileSecurity(inFile,outFile);	
fileSecurity.ChangePassword("owner","newuser","newowner", 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) 
fileSecurity.ChangePassword("owner","newuser","newowner", DocumentPrivilege.Print,KeySize.x256)

另请参阅


ChangePassword(string, string, string, DocumentPrivilege, KeySize, Algorithm)

通过所有者密码更改用户密码和密码,允许重置 Pdf 文档安全性。新用户密码和新所有者密码可以为 null 或空。如果新所有者密码为 null 或空,则所有者密码将被随机字符串替换。KeySize 和 Algorithm 值有 6 种可能的组合。然而 (KeySize.x40, Algorithm.AES) 和 (KeySize.x256, Algorithm.RC4) 是无效的,如果遇到这种组合,将引发相应的异常。如果处理失败,则抛出异常。

public bool ChangePassword(string ownerPassword, string newUserPassword, string newOwnerPassword, 
    DocumentPrivilege privilege, KeySize keySize, Algorithm cipher)
参数类型描述
ownerPassword字符串原始所有者密码。
newUserPassword字符串新用户密码。
newOwnerPassword字符串新所有者密码。
privilegeDocumentPrivilege重置安全性。
keySizeKeySizeKeySize.x40 表示 40 位加密,KeySize.x128 表示 128 位加密,KeySize.x256 表示 256 位加密。
cipherAlgorithmAlgorithm.AES 使用 AES 算法加密或 Algorithm.RC4 进行 RC4 加密。

返回值

成功返回 true。

示例

[C#]
string inFile = ".D:\\input.pdf"; //The TestPath may be re-assigned.
string outFile = "D:\\output.pdf";	//The TestPath may be re-assigned.
PdfFileSecurity fileSecurity = new PdfFileSecurity(inFile,outFile);	
fileSecurity.ChangePassword("owner","newuser","newowner", DocumentPrivilege.Print,KeySize.x256,Algorithm.AES);

[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) 
fileSecurity.ChangePassword("owner","newuser","newowner", DocumentPrivilege.Print,KeySize.x256,Algorithm.AES)

另请参阅