Files
SnapOtter/apps/docs/zh-CN/tools/image/barcode-generate.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

2.0 KiB
Raw Blame History

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
生成 Code 128、EAN-13、UPC-A、Code 39、ITF-14 和 Data Matrix 格式的条形码。 e84b1df40c7e human 7106840d576a

Barcode Generator

从文本输入生成条形码图像。支持 Code 128、EAN-13、UPC-A、Code 39、ITF-14 和 Data Matrix 格式。

API Endpoint

POST /api/v1/tools/image/barcode-generate

接受一个 application/json 请求体(而非 multipart)。条形码由提供的文本生成,而不是由上传的文件生成。

Parameters

Parameter Type Required Default Description
text string - 要编码到条形码中的文本(1-256 个字符)
type string "code128" 条形码格式:code128ean13upcacode39itf14datamatrix
scale integer 3 图像缩放系数(1-8
includeText boolean true 是否在条形码下方渲染文本

Example Request

curl -X POST http://localhost:1349/api/v1/tools/image/barcode-generate \
  -H "Authorization: Bearer si_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"text": "5901234123457", "type": "ean13", "scale": 4}'

Example Response

{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/barcode.png",
  "originalSize": 0,
  "processedSize": 4520
}

Notes

  • 与大多数工具不同,此端点接受 JSON 请求体而非 multipart 表单数据,因为条形码是从文本生成的,而不是从上传的文件生成的。
  • EAN-13 要求恰好 12 或 13 位数字。UPC-A 要求恰好 11 或 12 位数字。如果省略校验位,则会自动计算。
  • Code 128 是最灵活的格式,支持完整的 ASCII 字符集。
  • Data Matrix 生成二维条形码,适合在紧凑的方形中编码较长的字符串。