GS1-128 Barcode Generator in C#.

We all know that a barcode is a graphic symbol for identifying products. GS1‑128 barcodes are common in retail and enable reliable data exchange worldwide. In this article we will show how to generate GS1‑128 barcodes in C# and build a complete barcode generator.

The article covers these topics:

  1. C# GS1 128 Barcode Generator API
  2. What is GS1 Code 128 Barcode?
  3. Understanding the GS1 128 Barcode
  4. Generate GS1 128 Barcode in C#
  5. Generate UPC‑A GS1 128 Coupon
  6. Customize Barcode Appearance

C# GS1 128 Barcode Generator API

To generate GS1‑128 barcodes we use the Aspose.BarCode for .NET API. It supports a wide range of 1D and 2D barcode types.

The BarcodeGenerator class creates barcodes of a specified EncodeType. The EncodeType class defines which barcode format to use. Save the generated image with the Save(string) method.

Download the DLL or install via NuGet.

PM> Install-Package Aspose.BarCode

What is GS1 Code 128 Barcode?

GS1‑128 (formerly UCC/EAN‑128) is a machine‑readable product identifier that stores data about a product. It is applied to packs and containers to improve distribution and usage of goods.

Industries worldwide use the GS1 barcode or Global Trade Item Number (GTIN). It is recognized for food, pharmaceuticals, and many other commodities. The codes are defined by ISO and published by the GS1 organization.

Understanding the GS1 Code 128 Barcode

The GS1‑128 format follows this pattern:

(Application_Identifier_1)Application_Data(Application_Identifier_2)Application_Data

Key data that can be encoded includes:

  • GTIN (Global Trade Item Number)
  • Serial numbers
  • Batch and lot numbers
  • Product dates
  • Origin and destination
  • Product nature

Generate GS1 128 Barcode in C#

Create a GS1‑128 barcode generator in .NET by following these steps:

  1. Instantiate BarcodeGenerator with the desired EncodeType.
  2. Set the text to encode.
  3. Define the barcode size in pixels.
  4. Save the image with Save(), providing the file path.

The code below demonstrates how to generate a GS1‑128 barcode in C#.

Generate GS1-128 Barcode using C#

Generate GS1-128 Barcode using C#

Generate UPC‑A GS1 128 Coupon in C#

You can also create a barcode label that includes a GS1‑128 coupon. Set the EncodeType to UpcaGs1Code128Coupon in the first step.

The example below shows how to generate a UPC‑A GS1‑128 coupon in C#.

Generate UPC-A GS1 128 Coupon in C#

Generate UPC-A GS1 128 Coupon in C#

Customize GS1 128 Coupon Appearance in C#

You can customize the barcode’s appearance by setting additional properties before saving the image.

The snippet below illustrates how to customize the appearance of a GS1‑128 coupon in C#.

Customize the colors and coupon supplement space in C#

Customize the colors and coupon supplement space in C#

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

GS1 Code 128 Barcode Library - Learning Resources

Explore more features of Aspose.BarCode with these resources:

Conclusion

In this article we covered GS1‑128 barcodes and how to generate a GS1‑128 barcode in C#. We also demonstrated how to create a UPC‑A GS1‑128 coupon programmatically. Follow the steps to build your own customized GS1‑128 barcode generator. For questions, visit our free support forum.

See Also