UPC-A
- 2 minutes to read
UPC-A is a common retail barcode in the United States. The symbol encodes 12 digits, including a check digit.
Examples
Configure Barcode Settings (UPCAOptions)
Use the UPCAOptions class to configure UPC-A barcode settings.
The following code snippet creates a Universal Product Code (UPC-A) barcode and specifies its settings:

using DevExpress.Docs.Barcode;
using DevExpress.Drawing;
using System.Drawing;
var upcaOptions = new UPCAOptions();
upcaOptions.BackColor = Color.LightGray;
upcaOptions.ShowText = false;
upcaOptions.Padding = new Padding(5);
upcaOptions.BorderWidth = 1;
upcaOptions.BorderColor = Color.Blue;
using var upcaOptionsStream = new FileStream(Path.Combine(outDir, "barcode_symbology_upca.png"), FileMode.Create, FileAccess.Write);
using var upcaOptionsGenerator = new BarcodeGenerator(upcaOptions);
upcaOptionsGenerator.Export("72527273070", upcaOptionsStream, DXImageFormat.Png);
Configure Barcode Settings (Fluent API)
Use the UPCAOptionsBuilder class to configure UPC-A barcode settings with Fluent API.
The following code snippet creates a Universal Product Code (UPC-A) barcode and specifies its settings:

using DevExpress.Docs.Barcode;
using DevExpress.Drawing;
using System.Drawing;
var upcaCode = UPCAOptionsBuilder.Create()
.WithBackColor(Color.LightGray)
.WithShowText(false)
.WithPadding(5)
.WithBorderWidth(1)
.WithBorderColor(Color.Blue)
.Build();
var filePath = Path.GetFullPath("upca_code.png");
using var stream = new FileStream(filePath, FileMode.Create);
using var generator = new BarcodeGenerator(upcaCode);
generator.Export("72527273070", stream, DXImageFormat.Png);
Symbology-Specific Options
This symbology has no additional options.
See Also