创建数字签名 
创建数字签名分为两个步骤:
- 创建签名域 
- 在签名域填写签名 
通过这两个步骤,您可以自签文件,或邀请其他人在您创建的签名域进行签名。
创建签名域 
ComPDFKit 支持自定义签名域表单样式,以及通过文字,图片,手绘来自定义签名外观。
以下是创建签名域的示例代码:
javascript
docViewer.addAnnotations({
  type: 'signatureFields',
  rect: {
    left: 102,
    top: 136,
    right: 161,
    bottom: 156
  },
  pageIndex: 0
});在签名域中填写签名 
在签名域中填写签名的步骤如下:
- 持有一个 PKCS12 标准的证书(PFX或P12格式),并确保知道它的密码,您可以通过 ComPDFKit SDK 内置的方法创建符合标准的数字证书。 
- 通过 ComPDFKit 的接口设定数字签名的外观。 
- 将数据写入签名域并保存。 
在签名域中填写签名的示例代码:
javascript
const { subject } = await docViewer.loadCertificates({
  pkcs12Buffer: pkcs12.buffer,
  password: password
})
const content = "Name: " + subject.CN + "\n" +
  "Date: " + date + "\n" +
  "Reason: "+ 'I am the owner of the document.' +" \n" +
  "Location: "+ location + "\n"
docViewer.handleSign({
    type: 1,
    flag: 'save',
    param: {
      annotation,
      content,
      text: 'Text'
      isContentAlginLeft: false
    },
    pkcs12Buffer: pkcs12.buffer,
    password: password
  })