Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Zxing编码1d EAN8_C#_Zxing - Fatal编程技术网

C#Zxing编码1d EAN8

C#Zxing编码1d EAN8,c#,zxing,C#,Zxing,我想使用c#Zxing生成1D EAN8条形码。我只能找到生成二维二维二维码的代码示例和文档 var writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE, Options = new QrCodeEncodingOptions { Height = height, Width = width } }; return writer.Wr

我想使用c#Zxing生成1D EAN8条形码。我只能找到生成二维二维二维码的代码示例和文档

      var writer = new BarcodeWriter
  {
     Format = BarcodeFormat.QR_CODE,
     Options = new QrCodeEncodingOptions
     {
        Height = height,
        Width = width
     }
  };
  return writer.Write(textForEncoding);
我可以运行它,但没有“1dcodecodingoptions”或类似的命名函数。我试过了

      var writer = new BarcodeWriter
  {
     Format = BarcodeFormat.EAN_8

  };
  return writer.Write("1234567");
但它通过一个索引错误

编辑:我现在的语法是正确的,但它没有生成正确的条形码,因为我不知道它期望的大小,而且似乎没有默认值

使用ZXing; 使用ZXing.com

  var writer = new BarcodeWriter
  {
     Format = BarcodeFormat.EAN_8,
        Options = new ZXing.Common.EncodingOptions
        {
            Height = 100,
            Width = 300
        }
  };
  return writer.Write("12345678");

12345678不是有效的EAN8条形码。1234567的校验位为0。有关如何计算校验和的信息,请参阅

ZXing不会阻止您创建无效的条形码(至少在我使用的0.11版本中,尽管Codeplex上的当前源代码看起来是这样),但它们不会扫描。扫描仪使用校验和来确保正确读取数据

如果您打算在商业中使用EAN8,您需要从您的国家/地区获得GTIN-8。如果你只打算在你的商店里销售,你应该使用一种限制分销

如果您不需要将产品放入零售供应链,我建议使用不同的条形码格式

交错2/5(
BarcodeFormat.ITF
)非常紧凑,但只能包含数字;它没有任何自检功能,并且存在一个设计缺陷,允许从某些角度误读条形码。建议您在条形码的顶部和底部放置黑色条(称为承载条)。我在中兴看不到这个选项

第二个最紧凑的格式是代码128(BarcodeFormat.Code_128),使用代码集C。它在一个模块中编码两位数字(一块六条和空格)。格式是自我检查的(始终有一个检查字符,由扫描仪剥离)。有些扫描仪不能正确处理代码集C。要强制代码集B,请使用code128编码选项代替Common.EncodingOptions,并将forcecodesteb设置为true