GS1-128
Does IronBarcode Support GS1 UCC/EAN-128 Symbology?
Barcodes with GS1 are recognized and decoded accurately. However, the issue lies in the current lack of brackets in the displayed barcode value.
When using GS1-128, IronBarcode currently outputs: 01950123456789033103000123
(which is recognized as a Code 128 barcode with GS1 signature). The desired value to be displayed on the image output would be: 01950123456789033103000123
. However, the barcode scanner will output (01)95012345678903(3103)000123
with a detection of the barcode type as Code128
.
For generating a GS1-128 barcode, use the following code:
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");
}
}
Output barcode
The above code generates a GS1-128 barcode with a default divider. If you want to add additional dividers, you can insert the Unicode separator \u00f1
. However, note that when using the AddBarcodeValueTextBelowBarcode
method, the Unicode character ñ (code 0x00F1) will be displayed. To overcome this limitation, an alternative approach is to manipulate the string and pass the modified value to the AddAnnotationTextBelowBarcode
method. This way, you can achieve the desired display of the barcode value without the ñ character.
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");
}
}
Output barcode
When scanning the barcode, the output will be (01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000
, and the barcode type will be detected as GS1Code128
.