delphi llPDFLib 添加密码

llPDFLib 添加密码

属性和方法

TPDFDocument.Security

property Security: TPDFSecurityOptions;

它定义了与文档加密相关的属性。

TPDFSecurityOptions.State

property State: TPDFSecurityState;

PDF文档的加密方式。

TPDFSecurityOptions.UserPassword

property UserPassword: AnsiString;

当前PDF文档的用户密码。这是用于加密文件的密码。

TPDFSecurityState

PDF文档的加密状态。

unit

llPDFTypes

TPDFSecurityState = (
  ssNone,
  ss40RC4,
  ss128RC4,
  ss128AES,
  ss256AES
);
  • ssNone 没有加密的文档
  • ss40RC4 使用 RC4 加密的加密文档(40 位密钥长度)
  • ss128RC4 使用 RC4 加密的加密文档(128 位密钥长度)
  • ss128AES 使用 AES 加密的加密文档(128 位密钥长度)
  • ss256AES 使用 AES 加密的加密文档(256 位密钥长度)

例子

添加密码

uses llPDFDocument, llPDFTypes;

procedure TForm1.Button10Click(Sender: TObject);
var
  Pdf: TPDFDocument;
begin
  Pdf := TPDFDocument.Create(nil);
  try
    //创建PDF文档
    Pdf.AutoLaunch := True;
    Pdf.FileName := 'C:\Users\Administrator\Desktop\ceshi.pdf';
    //设置密码
    Pdf.Security.State := ss256AES;
    Pdf.Security.UserPassword := '123';
    Pdf.BeginDoc;
    Pdf.EndDoc;
  finally
    Pdf.Free;
  end;
end;
posted @ 2022-03-08 18:46  txgh  阅读(134)  评论(0编辑  收藏  举报