THotPDF.AddLoadedSignedSignatureField Method

在已載入文件中加入一個立即可簽署的簽章欄位。此欄位帶有保留 /ByteRange 與 /Contents 空間的簽章字典,因此文件存檔之後,SignPDFWithPFX、PreparePDFForSigning 與 InsertSignatureHex 就能簽署它。搭配 BeginIncrementalUpdate,這就是已簽署 PDF 取得第二個簽章的方式

宣告

function AddLoadedSignedSignatureField(PageIndex: Integer; X1, Y1, X2, Y2: Single;
  const AFieldName: AnsiString; ContentsBytes: Integer = 8192;
  const SubFilter: AnsiString = 'adbe.pkcs7.detached';
  const Reason: AnsiString = ''; const Location: AnsiString = '';
  const ContactName: AnsiString = ''): Integer;

單元

HPDFDoc

參數

名稱用途
PageIndex顯示簽章 widget 之已載入頁面的以零起始索引
X1, Y1, X2, Y2PDF 使用者空間中的 widget 矩形(單位為 point,原點在左下角);寬度與高度必須為正值
AFieldName新簽章欄位的名稱;不得為空,也不得與文件中既有欄位同名
ContentsBytes保留給 CMS 簽章的位元組數(寫入時以兩倍的十六進位位數表示);必須容得下完整簽章,包括憑證與任何時間戳記權杖
SubFilter簽章格式,例如 adbe.pkcs7.detached 或 ETSI.CAdES.detached
Reason, Location, ContactName簽章字典中選填的 /Reason、/Location 與 /ContactInfo 項目

傳回值

傳回新表單欄位的索引;當 PageIndex 超出範圍時傳回 -1

使用說明

範例

PDF := THotPDF.Create(nil);
try
  PDF.BeginIncrementalUpdate('Signed.pdf');
  PDF.AddLoadedSignedSignatureField(0, 300, 120, 500, 160, 'Approver', 8192,
    'adbe.pkcs7.detached', 'Approved');
  PDF.SaveIncrementalUpdate('Prepared.pdf');
finally
  PDF.Free;
end;
// Signs the reserved field; the first signature stays valid
THotPDF.SignPDFWithPFX('Prepared.pdf', 'SignedTwice.pdf', 'Signer.pfx', 'password');

相關 API