PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/专题/行业打印场景

工厂 MES 打印物料标签

报工或入库时由 MES 提交物料标签。接口不连接 PLC。标签语言按工位打印机配置。调用 POST /v1/print-jobs,API Key 只放在服务端。

面向 制造执行系统的开发

说明

MES 在报工点已经有批次和物料号。打印只是把这些字段变成标签。服务端生成 TSPL 或 ZPL,发给该工位的 printer_code。不要让工控机上的浏览器持有 API Key。打印机由门店电脑上的 Agent 主动连出,不需要公网 IP,也不需要把 9100 端口映射到互联网。

工位电脑运行 Agent。它和 PLC 没有关系。节拍由 MES 决定,接口只负责这一次提交很快返回 queued。

批次号做幂等键。重复报工的保护应该在 MES 里就有,打印键是第二道。

创建任务使用 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

    先绑定工位和打印机

    从 GET /v1/printers 拿到 code,写进工位或门店配置,不要弹出系统对话框。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  2. 02

    在业务系统里生成文件

    驱动打印机用 PDF。小票和条码指令用 raw。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  3. 03

    在业务事件发生时提交

    打包、支付、签到或扫码。不要每次自动保存都打。幂等键用业务单号。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  4. 04

    把结果给到现场

    queued 不是已经出纸。AGENT_OFFLINE 和 PRINT_ERROR 要显示给操作员。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

Node.js

// 报工标签
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': idempotencyKey,
  },
  body: JSON.stringify({
    printer_code: Number(process.env.PRINTER_CODE),
    content_type: 'raw',
    content: Buffer.from(payload).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" }

这一套的细节

dpi

工位配置里写上 203 或 300,模板按它生成。Agent 只打印你提交的内容,不会替你向平台拉取单据。Agent 只打印你提交的内容,不会替你向平台拉取单据。

失败不要当成报工失败的唯一标准

是否允许无标签入库,由 MES 决定。接口只提供任务状态。Agent 只打印你提交的内容,不会替你向平台拉取单据。Agent 只打印你提交的内容,不会替你向平台拉取单据。

常见问题

能读 PLC 吗?(详见本页)

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

有 MES 插件吗?(详见本页)

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

二维码?(详见本页)(详见本页)

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

网络隔离的车间?(详见本页)

Agent 需要访问 API 主机的出站 HTTPS。不需要车间打印机被外网访问。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

相关页面

  • 服装仓的吊牌和箱唛

    吊牌和箱唛通常不是同一台打印机,也不是同一种尺寸。按工序把任务发给对应的 code。调用 POST /v1/print-jobs,API Key 只放在服务端。

  • TSC TTP-244 Pro 远程打印条码标签

    TTP-244 Pro 是 TSC 的 203 dpi 桌面机,指令用 TSPL。SIZE 和 GAP 写在指令里,不是 JSON 字段。调用 POST /v1/print-jobs,API Key 只放在服务端。

  • 跨境 WMS 批量打印 SKU 标签

    复核或上架时按批发送 SKU 标签。每批使用稳定的幂等键,失败的一张单独补打。调用 POST /v1/print-jobs,API Key 只放在服务端。调用 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