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
- Introduction
- What Is GS1-128 (UCC/EAN-128) Barcode?
- Quick Start (Minimal Example)
- Prerequisites
- Step-by-Step Implementation
- Formatting Application Identifiers (AIs)
- Customizing Barcode Appearance
- Supported Output Formats
- Troubleshooting & Common Issues
- FAQs
- Use Cases and Applications
- Best Practices
- Related Articles
- 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
- GTIN-14:
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
Tip | Do | Don’t |
---|---|---|
AI Syntax | Use parentheses and correct field order | Use spaces or omit AIs |
Field Formatting | Concatenate AIs per GS1 specs | Mix GS1 and non-GS1 data |
Output Format | SVG/PNG/TIFF for compliance labels | Low-res JPG for packaging |
Validation | Test with GS1-compliant scanner/software | Assume 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.