Learn how to generate Codabar and Code 11 barcodes in .NET applications using Aspose.BarCode. This guide covers installation, barcode generation steps, customization options, and best practices for healthcare and library use cases.
Introduction
This article provides a detailed walkthrough on generating Codabar and Code 11 barcodes for healthcare, library, telecom, and parcel tracking applications using Aspose.BarCode for .NET. It includes step-by-step instructions, C# code examples, and tips for integrating these barcode types into your .NET projects.
What Are Codabar and Code 11 Barcodes?
Codabar is a numeric barcode widely used in blood banks, libraries, and parcel services, supporting digits 0-9 plus A-D for start/stop symbols. Code 11 is used for telecom inventory and identification, supporting digits 0-9 and dash (-). Both are simple, scanner-friendly, and ideal for institutional workflows.
Quick Start (Minimal Example)
The following minimal example demonstrates how to generate a Codabar barcode:
using Aspose.BarCode.Generation;
var generator = new BarcodeGenerator(EncodeTypes.Codabar, "A123456B");
generator.Save("codabar-bloodbank.png", BarCodeImageFormat.Png);
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
Codabar Example:
using Aspose.BarCode.Generation;
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Codabar, "A123456B");
gen.Save("codabar-bloodbank.png", BarCodeImageFormat.Png);
Code 11 Example:
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code11, "12345-6789");
gen.Save("code11-telecom.png", BarCodeImageFormat.Png);
Complete Example
Check Digit and Customization Options
- Code 11 Check Digit:
csgen.Parameters.Barcode.Code11.EnableChecksum = true;
- Bar Height/Width:
csgen.Parameters.Barcode.BarHeight.Pixels = 80; gen.Parameters.Barcode.XDimension.Pixels = 2;
- Color/Background:
csgen.Parameters.Barcode.BarColor = Color.MidnightBlue; gen.Parameters.Barcode.BackColor = Color.White;
- Caption:
csgen.Parameters.CaptionBelow.Visible = true;
Customizing Barcode Appearance
- See above for bar height, width, and color
- Adjust XDimension and BarHeight for label size
- Use SVG or PNG for crisp printing
Supported Output Formats
- PNG, JPEG, BMP – Print and digital
- TIFF – Archival or medical/lab printers
- SVG, EMF – Large-scale or digital labels
Troubleshooting & Common Issues
- Barcode not scanning?
- Use only valid characters; ensure proper start/stop symbols for Codabar.
- Checksum errors?
- Enable/disable checksum to match scanner or app expectations.
- Small label not fitting?
- Lower BarHeight and XDimension.
FAQs
Q: Are these barcodes accepted in modern healthcare and libraries? A: Yes—both are used worldwide for legacy and new workflows. Q: Can I encode text with Codabar? A: No—Codabar is numeric with A-D for start/stop only.
Use Cases and Applications
- Blood bank labeling (Codabar)
- Library and lending management
- Parcel and mail tracking
- Telecom asset/inventory (Code 11)
Best Practices: Quick Reference Table
Tip | Do | Don’t |
---|---|---|
Charset | Codabar: 0-9,A-D; Code 11: 0-9,- | Use letters or symbols |
Start/Stop | Use A-D for Codabar | Omit start/stop characters |
Output Format | SVG/PNG for crisp output | Low-res JPG for printing |
Check Digit | Enable if workflow requires | Enable randomly |
Conclusion
Codabar and Code 11 remain essential for healthcare, library, and legacy tracking workflows. Aspose.BarCode for .NET makes their generation and integration simple. See the Aspose.BarCode API Reference for more examples and options.
More in this category
- Create GS1-128 (UCC/EAN-128) Barcodes for Supply Chain and Compliance in .NET
- Create ISBN and ISSN Barcodes for Books and Periodicals in .NET
- Create UPC-A and UPC-E Barcodes for Product Packaging in .NET
- Extract QR Code Metadata Using Aspose.BarCode for .NET
- Generate Aztec Codes Using Aspose.BarCode for .NET