【问题标题】:How to use special char like CODEA in CODE_128如何在 CODE_128 中使用像 CODEA 这样的特殊字符
【发布时间】:2018-11-05 10:43:34
【问题描述】:

我正在尝试使用 ZXing 制作条形码,但我无法强制它使用 CODE_A 或 CODE_B 我试过了:

BarcodeWriter w = new BarcodeWriter();
w.Format = BarcodeFormat.CODE_128;
w.Options.GS1Format = false;
w.Options.Width = 1;
w.Options.Height = (int)(Heightmm * (g.DpiY / 25.4f));
Bitmap img = w.Write("0123456789");

生成 CODE_C 条码

然后用 CODE_A char (103) (Acording to Wikipedia) 加星标:

BarcodeWriter w = new BarcodeWriter();
w.Format = BarcodeFormat.CODE_128;
w.Options.GS1Format = false;
w.Options.Width = 1;
w.Options.Height = (int)(Heightmm * (g.DpiY / 25.4f));
Bitmap img = w.Write((char)103 +"0123456789");

但是只插入一个“g”(在 CODE_B 中)更改为 CODE_C 并插入“0123456789”

我也尝试过使用 end Code A char (106)

BarcodeWriter w = new BarcodeWriter();
w.Format = BarcodeFormat.CODE_128;
w.Options.GS1Format = false;
w.Options.Width = 1;
w.Options.Height = (int)(Heightmm * (g.DpiY / 25.4f));
Bitmap img = w.Write((char)103 +"0123456789" + (char)106);

但是这次生成的条码只在末尾插入了一个j

正确的做法是什么?

【问题讨论】:

  • 您只能尝试以下方法。也许这是您正在寻找的:var writer = new BarcodeWriter { Options = new Code128EncodingOptions { ForceCodesetB = true }, Format = BarcodeFormat.CODE_128 };

标签: c# .net zxing


【解决方案1】:

您不能通过将Start Code AStart Code B 等代码放入输入字符串中来强制 ZXing.NET 切换代码集。相反,它会分析您的输入字符串并根据支持的字符自动决定如何对其进行编码。

更多细节请阅读chooseCode方法on GitHub的实现。

【讨论】:

    猜你喜欢
    • 2021-11-17
    • 1970-01-01
    • 2012-09-18
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多