Generate Code 39 and Code 39 Full ASCII barcodes in .NET applications using Aspose.BarCode library. This guide provides step-by-step instructions, C# code samples, and customization tips for barcode appearance.
Introduction
This article explains how to generate Code 39 and Code 39 Full ASCII barcodes for asset management, inventory tracking, and other applications using Aspose.BarCode for .NET. It includes full C# code examples and advice on customizing the barcode’s appearance.
What Are Code 39 and Code 39 Full ASCII Barcodes?
Code 39 is a widely used 1D barcode that supports uppercase letters, numbers, and a few symbols—ideal for asset tags, inventory systems, library management, and ID cards. Code 79 Full ASCII (Extended) enables all ASCII characters by using special sequences.
Quick Start (Minimal Example)
The following minimal example demonstrates how to generate a basic Code 39 barcode in C#:
using Aspose.BarCode.Generation;
var generator = new BarcodeGenerator(EncodeTypes.Code39, "ABC1234");
generator.Save("asset-code39.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
Code 39 Example:
using Aspose.BarCode.Generation;
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code39, "ASSET2025");
gen.Save("asset-code39.png", BarCodeImageFormat.Png);
Code 39 Full ASCII (Extended) Example:
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code39Extended, "Asset#1234_ABC");
gen.Save("asset-code39ext.png", BarCodeImageFormat.Png);
Customizing Barcode Appearance
- Check Digit:
csgen.Parameters.Barcode.Code39.EnableChecksum = true;
- Bar Height/Width:
csgen.Parameters.Barcode.BarHeight.Pixels = 80; gen.Parameters.Barcode.XDimension.Pixels = 2;
- Color/Background:
csgen.Parameters.Barcode.BarColor = Color.DarkGreen; gen.Parameters.Barcode.BackColor = Color.White;
- Caption:
csgen.Parameters.CaptionBelow.Visible = true;
- Full ASCII Mode:
EncodeTypes.Code39Extended
Supported Output Formats
- PNG, JPEG, BMP – Print and web
- TIFF – High-res/archival
- SVG, EMF – Scalable graphics
Troubleshooting & Common Issues
- Barcode not scanning?
- Make sure only valid characters are used (A-Z, 0-9, - $ % . / + space for basic Code 39).
- For special characters, use Code39Extended.
- Checksum mismatch?
- Enable or disable checksum to match your scanner configuration.
- Small label not fitting?
- Adjust bar height and XDimension; use Code 39 over Code128 for less dense codes.
FAQs
Q: What’s the difference between Code 39 and Code 39 Full ASCII? A: Standard Code 39 supports only a limited character set. Full ASCII mode (Extended) enables all ASCII characters by encoding them as two-symbol sequences. Q: Is the check digit mandatory? A: It’s optional in Code 39. Enable it only if your workflow or scanner requires.
Use Cases and Applications
- Asset and equipment labeling
- Library and school management
- Inventory/stockroom tracking
- Industrial and ID badges
Best Practices: Quick Reference Table
Tip | Do | Don’t |
---|---|---|
Charset | Use A-Z, 0-9, -.$%./+ (basic) | Use lowercase in basic mode |
Full ASCII | Use Code39Extended for symbols | Expect symbols in basic mode |
Output Format | SVG/PNG for crisp output | Low-res JPG for printing |
Check Digit | Enable only if required | Enable randomly |
Conclusion
Code 39 is the backbone of asset, inventory, and library barcoding. Aspose.BarCode for .NET offers flexible options for every scenario. See the Aspose.BarCode API Reference for more advanced barcode features.
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