EncryptFile

EncryptFile(string, string, DocumentPrivilege, KeySize)

使用userpassword 和ownerpassword 加密Pdf 文件,并设置文档的访问权限。 用户密码和所有者密码可以为空或空。如果输入的所有者密码为空或为空,所有者密码将被替换为随机字符串 。 如果进程失败则抛出异常。

public bool EncryptFile(string userPassword, string ownerPassword, DocumentPrivilege privilege, 
    KeySize keySize)
范围类型描述
userPasswordString用户密码。
ownerPasswordString所有者密码。
privilegeDocumentPrivilege设置权限。
keySizeKeySizeKeySize.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);		
fileSecurity.EncryptFile("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) 
fileSecurity.EncryptFile("userpass", "ownerpass", DocumentPrivilege.Print, KeySize.x256)

也可以看看


EncryptFile(string, string, DocumentPrivilege, KeySize, Algorithm)

使用userpassword 和ownerpassword 加密Pdf 文件,并设置文档的访问权限。 用户密码和所有者密码可以为空或空。如果输入的所有者密码为空或为空,则所有者密码将被替换为随机字符串 。 KeySize 和 Algorithm 值有 6 种可能的组合。 但是 (KeySize.x40, Algorithm.AES) 和 (KeySize.x256, Algorithm.RC4) 无效,如果 kit 遇到这种组合,将引发相应的 异常。 如果处理失败则引发异常。

public bool EncryptFile(string userPassword, string ownerPassword, DocumentPrivilege privilege, 
    KeySize keySize, Algorithm cipher)
范围类型描述
userPasswordString用户密码。
ownerPasswordString所有者密码。
privilegeDocumentPrivilege设置权限。
keySizeKeySizeKeySize.x40 用于 40 位加密,KeySize.x128 用于 128 位加密, KeySize.x256 用于 256 位加密。
cipherAlgorithm使用 AES 算法进行加密的 Algorithm.AES 或用于 RC4 加密的 Algorithm.RC4。

返回值

真正的成功。

例子

[C#]
string inFile = "D:\\input.pdf"; //TestPath 可能会被重新分配。
string outFile = "D:\\output.pdf"; //TestPath 可能会被重新分配。	
PdfFileSecurity fileSecurity = new PdfFileSecurity(inFile,outFile);		
fileSecurity.EncryptFile("userpass","ownerpass",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.EncryptFile("userpass","ownerpass",DocumentPrivilege.Print,KeySize.x256,Algorithm.AES)

也可以看看