@ documenso/pdf- sign(签名)
这个软件包提供了使用各种签名方法签名PDF文件的功能,包括私人密钥,P12容器和Google Cloud. 其设计与多克门索站台相通.
安装
要安装软件包, 请运行 :
npm install @documenso/pdf-sign
使用量
用私人密钥签名
const { signWithPrivateKey } = require('@documenso/pdf-sign');
const content = Buffer.from('...'); // PDF content
const cert = Buffer.from('...'); // Certificate in PEM format
const privateKey = Buffer.from('...'); // Private key in PEM format
const signedPdf = await signWithPrivateKey({
content,
cert,
privateKey,
// Optional fields
signingTime: '2023-03-15T12:00:00Z', // ISO 8601 format
timestampServer: 'http://timestamp.server',
});
用P12集装箱签字
const { signWithP12 } = require('@documenso/pdf-sign');
const content = Buffer.from('...'); // PDF content
const p12 = Buffer.from('...'); // P12 container
const signedPdf = await signWithP12({
content,
cert: p12,
// Optional fields
password: 'p12password',
signingTime: '2023-03-15T12:00:00Z', // ISO 8601 format
timestampServer: 'http://timestamp.server',
});
与 Google 云签名
const { signWithGCloud } = require('@documenso/pdf-sign');
const content = Buffer.from('...'); // PDF content
const cert = Buffer.from('...'); // Certificate in PEM format
const keyPath = 'projects/project-id/locations/global/keyRings/keyring-name/cryptoKeys/key-name';
const signedPdf = await signWithGCloud({
content,
cert,
keyPath,
// Optional fields
signingTime: '2023-03-15T12:00:00Z', // ISO 8601 format
timestampServer: 'http://timestamp.server',
});
API 密码
signWithPrivateKey(options)
options.content(Buffer):PDF内容待签名.options.cert(Buffer):PEM格式的证书.options.privateKey(Buffer):PEM格式的私钥.options.signingTime(弦,可选): ISO 8601格式的签名时间.options.timestampServer(弦,可选): 时间戳服务器的 URL .
返回一个包含 PDF 签名的缓冲器解答的保证 .
signWithP12(options)
options.content(Buffer):PDF内容待签名.options.certP12集装箱.options.password(弦,可选): P12容器的密码.options.signingTime(弦,可选): ISO 8601格式的签名时间.options.timestampServer(弦,可选): 时间戳服务器的 URL .
返回一个包含 PDF 签名的缓冲器解答的保证 .
signWithGCloud(options)
options.content(Buffer):PDF内容待签名.options.cert(Buffer):PEM格式的证书.options.keyPath(字符串):谷歌云密钥路径.options.signingTime(弦,可选): ISO 8601格式的签名时间.options.timestampServer(弦,可选): 时间戳服务器的 URL .
返回一个包含 PDF 签名的缓冲器解答的保证 .
许可证
此软件包根据 AGPL-3.0 许可证。 。 。 .