Ask Your Question
3

How to create GS1-128 using ZXing.Net?

asked 2023-01-21 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-02-07 02:00:00 +0000

scrum gravatar image

To create a GS1-128 barcode using ZXing.Net, follow these steps:

  1. Install ZXing.Net package using NuGet Package Manager.

  2. Import the necessary namespaces:

using ZXing;
using ZXing.Common;
using ZXing.OneD;
  1. Create an instance of the BarcodeWriter class and set the encoding parameters:
var writer = new BarcodeWriter
{
     Format = BarcodeFormat.CODE_128,
     Options = new EncodingOptions
     {
         Width = 400,
         Height = 100,
         Margin = 10,
         PureBarcode = true,
     },
};
  1. Generate the barcode image by passing the data to be encoded as a string:
var barcode = writer.Write("(10)123456(17)200101(30)200101(21)A12345");
  1. Save or display the generated barcode image:
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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-01-21 11:00:00 +0000

Seen: 22 times

Last updated: Feb 07 '23