PDF 生成 API
通过 HTML 文件、HTML 字符串、HTML URL,或 HTML 模板加 JSON 数据生成 PDF 文件。
HTML 转 PDF
| 项目 | 值 |
|---|---|
| 请求地址 | POST http://localhost:8080/api/v1/process/pdf/generation/html-to-pdf |
| 认证 | x-api-key: your_api_key_here |
| 请求类型 | multipart/form-data |
| 成功响应 | PDF 文件流 |
参数
| 参数名 | 类型 | 说明 | 是否必填 |
|---|---|---|---|
htmlFile | File | HTML 文件;可与 request.html 或 request.htmlUrl 三选一。 | 否 |
request.html | String | HTML 字符串。 | 否 |
request.htmlUrl | String | HTTP/HTTPS HTML 地址。 | 否 |
request.baseUri | String | 相对资源基准路径或 URL。 | 否 |
request.pageSize | Object | 页面宽高,单位 pt。 | 否 |
request.outputFileName | String | 输出文件名。 | 否 |
curl 示例
bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/generation/html-to-pdf" \
-H "x-api-key: your_api_key_here" \
-F "[email protected]" \
-F 'request={"pageSize":{"width":595,"height":842},"outputFileName":"report.pdf"}' \
-o report.pdf模板转 PDF
| 项目 | 值 |
|---|---|
| 请求地址 | POST http://localhost:8080/api/v1/process/pdf/generation/template-to-pdf |
| 认证 | x-api-key: your_api_key_here |
| 请求类型 | multipart/form-data |
| 成功响应 | PDF 文件流 |
参数
| 参数名 | 类型 | 说明 | 是否必填 |
|---|---|---|---|
templateFile | File | HTML 模板文件;可与 request.template 二选一。 | 否 |
dataFile | File | JSON 数据文件;可与 request.data 二选一。 | 否 |
request.template | String | HTML 模板字符串。 | 否 |
request.data | Object/String | 模板数据。 | 否 |
request.baseUri | String | 相对资源基准路径或 URL。 | 否 |
request.pageSize | Object | 页面宽高,单位 pt。 | 否 |
request.outputFileName | String | 输出文件名。 | 否 |
curl 示例
bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/generation/template-to-pdf" \
-H "x-api-key: your_api_key_here" \
-F "[email protected]" \
-F 'request={"data":{"invoiceNumber":"INV-001","customer":"Acme"},"outputFileName":"invoice.pdf"}' \
-o invoice.pdf