GS1-128
IronBarcode 是否支持 GS1 UCC/EAN-128 条码体系?
采用 GS1 标准的条形码能够被准确识别和解码。 然而,问题在于目前显示的条形码值缺少括号。
使用 GS1-128 时,IronBarcode 目前输出: 01950123456789033103000123 (被识别为带有 GS1 签名的 Code 128 条形码)。 图像输出上要显示的值应为: 01950123456789033103000123 。 但是,条形码扫描器将输出(01)95012345678903(3103)000123 ,检测到的条形码类型为Code128 。
要生成 GS1-128 条形码,请使用以下代码:
using IronBarCode;
class BarcodeExample
{
static void Main()
{
// Create a GS1-128 barcode using the specified value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);
// Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode();
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}using IronBarCode;
class BarcodeExample
{
static void Main()
{
// Create a GS1-128 barcode using the specified value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);
// Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode();
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}输出条形码
! 输出条形码示例
上述代码生成带有默认分隔符的 GS1-128 条形码。 如果要添加其他分隔符,可以插入 Unicode 分隔符\u00f1 。 但是请注意,使用AddBarcodeValueTextBelowBarcode方法时,将显示 Unicode 字符 ñ(代码 0x00F1)。 为了克服这一限制,另一种方法是操作字符串并将修改后的值传递给AddAnnotationTextBelowBarcode方法。 这样,您就可以在不显示 ñ 字符的情况下实现所需的条形码值显示。
using IronBarCode;
class BarcodeExampleWithAnnotation
{
static void Main()
{
// Original barcode value
string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";
// Remove unwanted unicode characters for display purposes
string trimmedString = barcodeValue.Replace("\u00f1", "");
// Create a GS1-128 barcode using the original value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);
// Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString);
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}using IronBarCode;
class BarcodeExampleWithAnnotation
{
static void Main()
{
// Original barcode value
string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";
// Remove unwanted unicode characters for display purposes
string trimmedString = barcodeValue.Replace("\u00f1", "");
// Create a GS1-128 barcode using the original value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);
// Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString);
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}输出条形码
扫描条形码时,输出结果为(01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000 ,条形码类型将被检测为GS1Code128 。






