How to Create GS1-128 (UCC/EAN-128) Barcodes for Supply Chain and Compliance in .NET

How to Create GS1-128 (UCC/EAN-128) Barcodes for Supply Chain and Compliance in .NET

What Is GS1-128 (UCC/EAN-128) Barcode?

GS1-128, also known as UCC/EAN-128, is a standardized 1D barcode for encoding variable-length, structured supply chain data with Application Identifiers (AIs)—used globally for logistics, healthcare, pharma, food, and retail. GS1-128 enables batch, lot, expiry, and serial tracking, and is mandatory for many compliance-driven industries.


Quick Start (Minimal Example)

using Aspose.BarCode.Generation;
var generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(01)09521234543213(10)ABC123");
generator.Save("gs1-128-shipment.png", BarCodeImageFormat.Png);

Table of Contents

  1. Introduction
  2. What Is GS1-128 (UCC/EAN-128) Barcode?
  3. Quick Start (Minimal Example)
  4. Prerequisites
  5. Step-by-Step Implementation
  6. Formatting Application Identifiers (AIs)
  7. Customizing Barcode Appearance
  8. Supported Output Formats
  9. Troubleshooting & Common Issues
  10. FAQs
  11. Use Cases and Applications
  12. Best Practices
  13. Related Articles
  14. Conclusion

Introduction

This guide demonstrates how to generate GS1-128 (UCC/EAN-128) barcodes for global supply chain, pharmaceutical, and regulatory compliance using Aspose.BarCode for .NET. Includes real C# code, AI formatting, and tips for validated output.


Prerequisites

  • Visual Studio 2019 or later
  • .NET 6.0+ or .NET Framework 4.6.2+
  • Aspose.BarCode for .NET (NuGet)
  • Basic C# knowledge
PM> Install-Package Aspose.BarCode 

Step-by-Step Implementation

using Aspose.BarCode.Generation;
// Example with GTIN-14 (01) and batch/lot (10)
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.GS1Code128, "(01)09521234543213(10)ABC123");
gen.Save("gs1-128-shipment.png", BarCodeImageFormat.Png);

Formatting Application Identifiers (AIs)

  • Start each data element with its AI in parentheses, e.g., (01), (17), (10), (21)

  • For variable-length fields (batch, lot, serial), group AI and data with no space, and terminate with a FNC1 if more fields follow (Aspose.BarCode does this automatically)

  • Examples:

    • GTIN-14: (01)09521234543213
    • Batch/Lot: (10)ABC123
    • Expiry: (17)250430

Customizing Barcode Appearance

  • Bar Height/Width: csgen.Parameters.Barcode.BarHeight.Pixels = 100; gen.Parameters.Barcode.XDimension.Pixels = 3;
  • Color/Background: csgen.Parameters.Barcode.BarColor = Color.Black; gen.Parameters.Barcode.BackColor = Color.White;
  • Caption: csgen.Parameters.CaptionBelow\.Visible = true;

Supported Output Formats

  • PNG, JPEG, BMP – Standard print and web
  • TIFF – High-res/archival
  • SVG, EMF – Vector for labeling and packaging

Troubleshooting & Common Issues

  • Barcode not scanning or wrong data?

    • Ensure correct AI syntax, correct use of parentheses, and no extra spaces.
  • Variable-length field not parsed?

    • Confirm proper FNC1 placement (handled by Aspose.BarCode automatically for GS1-128).
  • Too dense/large for label?

    • Adjust XDimension or use multi-row formatting.

FAQs

Q: How do I encode multiple data fields? A: Concatenate multiple AI-data pairs (e.g., (01)...(10)...(17)...).

Q: Are GS1-128 barcodes required for pharma and food exports? A: Yes, for many regions and industries—always validate with your compliance standards.


Use Cases and Applications

  • Global supply chain tracking
  • Pharmaceutical batch/expiry labeling
  • Food and beverage logistics
  • Healthcare device compliance
  • Warehouse and shipping automation

Best Practices: Quick Reference Table

TipDoDon’t
AI SyntaxUse parentheses and correct field orderUse spaces or omit AIs
Field FormattingConcatenate AIs per GS1 specsMix GS1 and non-GS1 data
Output FormatSVG/PNG/TIFF for compliance labelsLow-res JPG for packaging
ValidationTest with GS1-compliant scanner/softwareAssume all scanners are GS1-ready

Conclusion

GS1-128 (UCC/EAN-128) is essential for supply chain, healthcare, and regulatory barcoding. Aspose.BarCode for .NET provides robust tools for GS1-compliant barcode generation. See the Aspose.BarCode API Reference for more.

 English