【问题标题】:'' is not a valid code for a 3 of 9 standard bar code'' 不是 3 of 9 标准条码的有效代码
【发布时间】:2019-10-29 08:46:43
【问题描述】:

我想使用 .NET PDFSharp 库生成条形码。我正在创建一个 Barcode 实例

BarCode barcode = new Code3of9Standard
{
    Text = content, // example: 'this text will be converted to a barcode'
    StartChar = '*',
    EndChar = '*',
    Size = (XSize)(new XPoint(120, 20)), // for testing purposes
};

但不幸的是实例创建抛出了这个异常

'' 不是 3 of 9 标准条码的有效代码。

我也尝试设置Code 属性,但没有。构造函数提供了一些重载,所以我尝试了这个

BarCode barcode = new Code3of9Standard(content, (XSize)(new XPoint(120, 20)));

然后我得到错误

“此文本将被转换为条形码”不是 3 of 9 标准条形码的有效代码。

我从这里拿了例子

https://csharp.hotexamples.com/en/examples/PdfSharp.Drawing.BarCodes/Code3of9Standard/-/php-code3of9standard-class-examples.html

有人知道如何正确设置条形码实例以便我可以将其用于绘图功能

graphics.DrawBarCode(barcode, Brush, TopLeftOffset);

【问题讨论】:

  • content 字符串的值是多少?条形码 39 对允许的字符有一些限制。
  • 该值是可自定义的字符串。目前它是一个生成的字符串Lot: Pnnnnnnnn; dd-MMM-yyyy HH:mm:ss; Scan Operator: [alias]; Page: n/m; Scan Profile: [name version]
  • 您尝试编码的符号似乎对 Code39 无效。你有什么理由需要使用 Code39?
  • 我不这么认为。我想我也可以使用其他的,但似乎 Code3of9Standard 是标准的?
  • @phuzi 你会推荐使用 PDFSharp 的其他条形码吗?

标签: c# pdfsharp


【解决方案1】:

来自Code 39 Barcode FAQ & Tutorial

Code 39 字符集的符号系统由代表数字 0-9、大写字母 A-Z、空格字符和以下符号的条形码符号组成: – 。 $ / + %。小写字符也可以使用 IDAutomation Code-39 字体包中提供的扩展字体轻松编码。

如果不购买IDAutomation Code-39 Font Package,您将不得不坚持使用大写字母 (A-Z)、didits (0-9) 和一些符号 (–.$/+%)。

您链接的样本均未使用小写字母。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-22
    • 2010-10-15
    • 1970-01-01
    • 2016-05-27
    • 2012-10-04
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    相关资源
    最近更新 更多