THotPDF.UserPassword Property

 

THotPDF.UserPassword

THotPDF

 

顶部  上一页  下一页

Determines document user password.

 

Delphi 语法:

property UserPassword: AnsiString;

 

C++ 语法:

__property AnsiString UserPassword;

 

说明

用正确 user password 打开文档(或打开没有 user password 的文档)后,可按文档 encryption dictionary 中指定的 user access permissions 执行其他操作

 

如果用户尝试打开带 user password 的加密文档,viewer application 应提示输入密码。正确提供任一密码都允许用户打开文档并在屏幕上显示。如果文档没有 user password,则不会请求密码

 

使用 AES-256 加密(revision 5 或 6)时,密码按 UTF-8 计,且只使用前 127 字节,这是 ISO 32000-2 的规定。HotPDF 会把 AnsiString 从其代码页(通常是系统代码页)转换过来,因此含非 ASCII 字母的密码在任何合规阅读器中都能打开文件。代码页无法表示的字母,在把 Unicode 字符串赋给这个 AnsiString 属性时会丢失。RC4 和 AES-128 则按给定字节使用密码

 

代码示例

HPDF.OwnerPassword := 'password';          // Set owner password (required to change security settings)
HPDF.UserPassword := 'user';               // Set user password (required to open the document)
HPDF.ProtectOptions := [prPrint, prInformationCopy]; // Allow printing and copying only
HPDF.ActivateProtection := true;           // Enable PDF security

 

另请参阅: ActivateProtection, CryptKeyLength, OwnerPassword, ProtectOptions