1 | initial version |
To create a GS1-128 barcode using ZXing.Net, follow these steps:
Install ZXing.Net package using NuGet Package Manager.
Import the necessary namespaces:
using ZXing;
using ZXing.Common;
using ZXing.OneD;
var writer = new BarcodeWriter
{
Format = BarcodeFormat.CODE_128,
Options = new EncodingOptions
{
Width = 400,
Height = 100,
Margin = 10,
PureBarcode = true,
},
};
var barcode = writer.Write("(10)123456(17)200101(30)200101(21)A12345");
barcode.Save("gs1-128.png", ImageFormat.Png);
pictureBox1.Image = barcode;
The example above generates a GS1-128 barcode with the data "(10)123456(17)200101(30)200101(21)A12345". This data contains four elements: the Global Trade Item Number (GTIN), the expiration date, the production date, and a serial number. GS1-128 barcodes can include many other data elements depending on the needs of the barcode user.