Golang: GS1条形码生成

huangapple go评论125阅读模式
英文:

Golang: GS1 Barcode Generation

问题

你好,我正在尝试在Golang中生成GS1-128条形码,目前我能够将其呈现为GS1-128条形码,但它被扫描为Code-128条形码,而且它包含了<FNC1>而不是(

encoded, _ := code128.Encode("(343)12332(23)32123123")
key := barcode.Register(encoded)
var width = 72.0
var height = 15.0
barcode.Barcode(pdf, key, 50, 50, width, height, false)

有什么想法吗?

英文:

Hello i am trying to generate a GS1-128 Barcode in golang and currently i am able to get it to render the same as a GS1-128 Barcode but it scans as code-128 barcode and it has &lt;FNC1&gt; instead of (

encoded, _ := code128.Encode(&quot;(343)12332(23)32123123&quot;)
key := barcode.Register(encoded)
var width = 72.0
var height = 15.0
barcode.Barcode(pdf, key, 50, 50, width, height, false)

Any ideas?

答案1

得分: 4

GS1-128 是 Code128。GS1 仅仅使用了 Code128 符号中数据的特定编码方式。对于你的示例文本,(343)12332(23)32123123,括号中的数字是应用标识符,指示如何解释后面的数据值。而这些括号是用于在条形码下方显示可供人类阅读的文本。实际的条形码使用 代码来指示接下来的数字是一个应用标识符。

不幸的是,343 是一个无效的应用标识符,所以无法进一步解析你的示例。

如果你想要将你的条形码与一个验证条形码生成器进行比较,你可以使用 bwip-js 的公共 API(我是 bwip-js 的作者)。以下是你的示例文本的 URL:

https://api-bwipjs.metafloor.com/?bcid=gs1-128&amp;text=(343)12332(23)32123123&amp;includetext&amp;padding=10

英文:

GS1-128 is code128. GS1 just uses a specific encoding of the data within the code128 symbology. For your example text, (343)12332(23)32123123, the numbers in parentheses are application-identifiers that indicate how to interpret the following data value. And those parentheses are for the human-readable text displayed below the barcode. The actual barcode uses the &lt;FNC1&gt; code to indicate that the next set of numbers are an application identifier.

Unfortunately, 343 is an invalid AI, so it is not possible to dissect your example any further.

If you would like to compare your barcodes with a validating barcode generator, you can use the bwip-js public API (I am the author of bwip-js). The following is the URL for your example text:

https://api-bwipjs.metafloor.com/?bcid=gs1-128&amp;text=(343)12332(23)32123123&amp;includetext&amp;padding=10

huangapple
  • 本文由 发表于 2023年8月9日 09:32:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76864028-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定