【问题标题】:"Codabar" barcode generator by Zxing failed in Xamarin.iosZxing 的“Codabar”条形码生成器在 Xamarin.ios 中失败
【发布时间】:2016-06-25 10:32:06
【问题描述】:

我想同时显示 QR 码和 Codabar 码。

这是我的代码。

var qrcodeWriter = new ZXing.Mobile.BarcodeWriter {
    Format = ZXing.BarcodeFormat.QR_CODE,
    Options = new ZXing.Common.EncodingOptions {
        Width = 400,
        Height = 400,
       Margin = 1
    }
};
var qrcode = qrcodeWriter.Write (order.order_number);
imageQR.Image = qrcode;

var barcodeWriter = new ZXing.Mobile.BarcodeWriter {
    Format = ZXing.BarcodeFormat.CODABAR,
    Options = new ZXing.Common.EncodingOptions {
        Width = 400,
        Height = 80,
        Margin = 1
    }
};
var barcode = barcodeWriter.Write (order.order_number);
imageBar.Image = barcode;

QR 码成功但 codabar 在barcodeWriter.write 函数中失败。

请帮帮我。

错误代码:

ex {System.ArgumentException: Cannot encode : 'T' at ZXing.OneD.CodaBarWriter.encode (System.String co...} System.ArgumentException

调用堆栈:

MasterBee.HistoryDe​​tailViewController.ViewDidLoad() in /Volumes/Untitled/MsterBee_TEMP/MasterBee/ViewControllers/History/HistoryDe​​tailViewController.cs:69

UIKit.UIApplication.UIApplicationMain() 在 UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) 在 /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/UIKit/UIApplication.cs:79

UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/UIKit/UIApplication.cs:63

MasterBee.Application.Main(string[] args) in /Volumes/Untitled/MsterBee_TEMP/MasterBee/Main.cs:15

【问题讨论】:

  • 您的错误/异常是什么?
  • ex {System.ArgumentException:无法在 ZXing.OneD.CodaBarWriter.encode 编码:'T'(System.String co…} System.ArgumentException
  • 请通过编辑问题添加异常和堆栈跟踪。
  • 我添加了错误代码
  • 堆栈跟踪在哪里?

标签: ios xamarin.ios barcode zxing


【解决方案1】:

错误信息“Cannot encode 'T'”表示应该编码的内容不能编码为 Codabar。如果不知道“order.order_number”的值,就不可能说出内容有什么问题。 通常,如果要将其编码为 Codabar,则仅允许在内容的开头和结尾使用字符“T”。 示例:T1234567890T 可以,T12345T67890T 不行。

【讨论】:

  • 谢谢你的好意。
【解决方案2】:

我找到了原因。

它是 CODABAR 的格式。

条码有不同的格式。

因此,如果您使用 QRcode 的格式文本制作 CODABAR,那么它会崩溃。

另外,CODE_128和二维码的格式是一样的。

【讨论】:

    猜你喜欢
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-02
    相关资源
    最近更新 更多