Code 39 (USD-3)
- 2 minutes to read
Code 39, also known as 3 of 9 Code or USD-3, is a widely used alphanumeric symbology for non-retail environments. The United States Department of Defense and the Health Industry Bar Code Council (HIBCC) use Code 39. The symbology encodes 43 characters.
Examples
Configure Barcode Settings (Code39Options)
Use the Code39Options class to configure code 39 barcode settings.
The following code snippet creates an Code 39 barcode and customizes its options:

using DevExpress.Docs.Barcode;
using DevExpress.Drawing;
using System.Drawing;
var code39Options = new Code39Options();
code39Options.ShowText = true;
code39Options.Padding = new Padding(5);
code39Options.WideNarrowRatio = 3.0f;
code39Options.CalculateChecksum = true;
code39Options.BorderWidth = 1;
using var code39OptionsStream = new FileStream(Path.Combine(outDir, "barcode_symbology_code39.png"), FileMode.Create, FileAccess.Write);
using var code39OptionsGenerator = new BarcodeGenerator(code39Options);
code39OptionsGenerator.Export("CODE39", code39OptionsStream, DXImageFormat.Png);
Configure Barcode Settings (Fluent API)
Use the Code39OptionsBuilder class to configure code 39 barcode settings with Fluent API.
The following code snippet creates an Code 39 barcode and customizes its options:

using DevExpress.Docs.Barcode;
using DevExpress.Drawing;
using System.Drawing;
var code39Options = code39OptionsBuilder.Create()
.WithShowText(true)
.WithPadding(5)
.WithWideNarrowRatio(3.0f)
.WithCalculateChecksum(true)
.WithBorderWidth(1)
.Build();
using var code39OptionsStream = new FileStream(Path.Combine(outDir, "barcode_symbology_code39.png"), FileMode.Create, FileAccess.Write);
using var code39OptionsGenerator = new BarcodeGenerator(code39Options);
code39OptionsGenerator.Export("CODE39", code39OptionsStream, DXImageFormat.Png);
Symbology-Specific Options
| Property | Description |
|---|---|
| CalculateChecksum | Gets or sets whether to calculate and add a check character to barcode data. |
| WideNarrowRatio | Gets or sets the wide bar to a narrow bar ratio. |
See Also