PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/专题/平台打印接入

钉钉或飞书审批通过后自动打印 PDF

审批通过的回调发到你的服务器,再把 PDF 单据打到办公室打印机。没有钉钉或飞书插件。调用 POST /v1/print-jobs,API Key 只放在服务端。

面向 希望审批完成后自动出纸的企业内部系统

说明

钉钉和飞书负责审批流。打印机在办公室电脑上。审批通过的回调应进入你的服务器,由服务器生成或取出 PDF,再调用打印接口。本产品没有钉钉或飞书应用市场里的打印插件。打印机由门店电脑上的 Agent 主动连出,不需要公网 IP,也不需要把 9100 端口映射到互联网。

不要在审批表单的前端脚本里放 API Key。回调验签之后再打。printer_code 可以按部门或办公地点选择,存在你的配置表里。

Idempotency-Key 用审批实例 id。审批平台重试回调时不会打出两份。补打用新 key。

创建任务使用 POST /v1/print-jobs,请求头 Authorization: Bearer,正文包含 printer_code、content_type(pdf 或 raw)以及 content 或 content_url 二者之一。免费套餐是一台电脑每月 100 个任务。

创建任务使用 POST /v1/print-jobs,请求头 Authorization: Bearer,正文包含 printer_code、content_type(pdf 或 raw)以及 content 或 content_url 二者之一。免费套餐是一台电脑每月 100 个任务。

接入步骤

  1. 01

    订阅审批通过事件

    在你的 HTTPS 服务里验签。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  2. 02

    取得要印的 PDF

    由你的业务系统生成。审批意见本身不是打印接口能理解的版式。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  3. 03

    按地点选打印机

    前台和仓库不是同一个 printer_code。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  4. 04

    POST pdf 任务

    Bearer 密钥只在服务器。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  5. 05

    把 job id 回写到审批备注或你的台账

    方便行政查询是否 AGENT_OFFLINE。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

Node.js

// 审批回调:打印 PDF 单据
const res = await fetch('https://api.printbase.cloud/v1/print-jobs', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PRINTBASE_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': `approval:${instanceId}`,
  },
  body: JSON.stringify({
    printer_code: Number(process.env.PRINTER_CODE),
    content_type: 'pdf',
    content: pdf.toString('base64'),
    copies: 1,
  }),
});
if (!res.ok) throw new Error(`PrintBase ${res.status}: ${await res.text()}`);
const job = await res.json();
// { id: "job_abc", status: "queued" }

这一套的细节

回调重试

平台会重放 HTTP 回调。Idempotency-Key 必须稳定,body 也必须稳定,否则返回 409。Agent 只打印你提交的内容,不会替你向平台拉取单据。

怎样确认已经打出来

创建接口返回 id 和 status queued。之后是 queued、dispatched、printing、completed。失败原因包括 AGENT_OFFLINE、PRINTER_OFFLINE、DOWNLOAD_FAILED、PRINT_ERROR、INVALID_CONTENT。用 GET /v1/print-jobs/{id} 查询。Webhook 只在付费套餐提供,且只有 print_job.completed 和 print_job.failed。

常见问题

有钉钉或飞书官方插件吗?

没有。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

可以打印附件吗?(详见本页)

可以,如果附件是 PDF,且你的服务器能读到字节。Word 要先转成 PDF。接口只接受 pdf 或 raw。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

员工在家审批,纸在公司?

可以。Agent 在公司电脑上。审批人的笔记本不必安装打印机。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

多部门不同打印机?(详见本页)

在你的映射表里根据部门选 printer_code。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

相关页面

  • 金蝶云星空如何自动打印出库单

    出库单 PDF 由你的星空侧服务或中间程序提交给打印接口。没有金蝶认证插件,也不把打印机暴露到公网。调用 POST /v1/print-jobs,API Key 只放在服务端。

  • 异地打印:不做 VPN,也不做内网穿透

    门店 Agent 主动连出。总部服务器只访问 HTTPS 接口。不要把打印机 9100 端口映射到公网。调用 POST /v1/print-jobs,API Key 只放在服务端。

  • 用 Python 远程打印 PDF

    Python 标准库即可把 PDF 提交到打印接口。与英文 Python PDF 页是同一调用。调用 POST /v1/print-jobs,API Key 只放在服务端。

免费套餐:一台电脑每月 100 个任务,不需要信用卡。

免费注册查看 API 文档
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds