# @documenso/pdf-sign 中文文档

规范地址：https://npmcn.com/package/%40documenso/pdf-sign/

版本：0\.1\.0
npm 元数据更新时间：2024-03-15T03:20:32.585Z
中文译文更新时间：2026-11-12T14:36:41.951Z
软件包许可：AGPL-3\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40documenso/pdf-sign
原文对照：https://npmcn.com/package/%40documenso/pdf-sign/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：61.7 kB，16 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>= 10
- 运行依赖：0 个
- 首次发布：2024-03-15T03:20:31.753Z
- 最新版本发布：2024-03-15T03:20:32.064Z
- 近 30 天下载量：4543（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：1（近 12 个月 0 个）

## 中文简介

这个软件包提供了使用各种签名方法签名PDF文件的功能,包括私人密钥,P12容器和Google Cloud. 其设计与多克门索站台相通.

## 安装

```sh
npm install @documenso/pdf-sign
```

也可以使用：`pnpm add @documenso/pdf-sign`、`yarn add @documenso/pdf-sign`、`bun add @documenso/pdf-sign`

## README

# @ documenso/pdf- sign(签名)

这个软件包提供了使用各种签名方法签名PDF文件的功能,包括私人密钥,P12容器和Google Cloud. 其设计与多克门索站台相通.

## 安装

要安装软件包, 请运行 :

```bash
npm install @documenso/pdf-sign
```

## 使用量

### 用私人密钥签名

```javascript
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集装箱签字

```javascript
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 云签名

```javascript
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.cert` P12集装箱.
-   `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 许可证](https://npmcn.com/package/%40documenso/pdf-sign/LICENSE.txt)。 。 。 .

## 常见问题

### @documenso/pdf-sign 是什么？

这个软件包提供了使用各种签名方法签名PDF文件的功能,包括私人密钥,P12容器和Google Cloud\. 其设计与多克门索站台相通\.

### 如何安装 @documenso/pdf-sign？

在项目目录运行 npm install @documenso/pdf-sign，或使用 pnpm add / yarn add / bun add。

### @documenso/pdf-sign 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @documenso/pdf-sign 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @documenso/pdf-sign 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>= 10。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @documenso/pdf-sign 可以商用吗？

@documenso/pdf-sign 使用 AGPL-3\.0 许可。最严格的 Copyleft：除分发外，通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括，不构成法律意见，请以许可原文为准。

### @documenso/pdf-sign 的下载量有多少？

根据 npm 官方下载统计，@documenso/pdf-sign 在 2026/10/13 – 2026/11/11 这 30 天内被下载 4,543 次，日均约 151 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @documenso/pdf-sign 还在维护吗？

最新版本 0\.1\.0 发布于 2024/03/15（2 年前）；至今共发布 1 个版本，其中过去 12 个月发布了 0 个；首次发布于 2024/03/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

