How to Generate Code 39 and Code 39 Full ASCII Barcodes with Custom Text in .NET
What Are Code 39 and Code 39 Full ASCII Barcodes?
Code 39 is a widely used 1D barcode supporting uppercase letters, numbers, and a few symbols—ideal for asset tags, inventory, library systems, and ID cards. Code 39 Full ASCII (Extended) enables all ASCII characters by using special sequences.
Quick Start (Minimal Example)
using Aspose.BarCode.Generation;
var generator = new BarcodeGenerator(EncodeTypes.Code39, "ABC1234");
generator.Save("asset-code39.png", BarCodeImageFormat.Png);
Table of Contents
- Introduction
- What Are Code 39 and Code 39 Full ASCII Barcodes?
- Quick Start (Minimal Example)
- Prerequisites
- Step-by-Step Implementation
- Customizing Barcode Appearance
- Supported Output Formats
- Troubleshooting & Common Issues
- FAQs
- Use Cases and Applications
- Best Practices
- Related Articles
- Conclusion
Introduction
This article explains how to generate Code 39 and Code 39 Full ASCII barcodes for asset management, library systems, and inventory workflows using Aspose.BarCode for .NET. Full C# code and customization advice are included.
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.