Skip to main content

Barcode Options

  • 2 minutes to read

DevExpress.Docs.Barcode API allows you to configure common barcode options, set symbology-specific options, and generate images for use in your application or documents.

Common Options

Use the following options for most symbologies:

Category Key options
Appearance BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth
Layout RotationAngle, Padding, Margin, SizeMode
Output Dpi, ModuleSize, Unit, Width, Height
Text ShowText, TextFont, CodeTextHorizontalAlignment, CodeTextVerticalAlignment

Symbology-Specific Options

Set up an options object based on symbology type (QRCodeOptions for QR Codes, Code128Options for Code 128 barcodes, and so on).

Review the list of available symbologies: Barcode Types.

Example

The following example sets common options and QR Code-specific options, then exports a PNG image:

DevExpress Barcode Generator - QR Code barcode

using System.IO;
using DevExpress.Docs.Barcode;
using DevExpress.Drawing;

// Create QR Code options.
var qrOptions = new QRCodeOptions();

// Common options.
qrOptions.BackColor = DXColor.LightGray;
qrOptions.ForeColor = Color.DarkGreen;
qrOptions.BorderColor = DXColor.DarkCyan;
qrOptions.BorderStyle = BorderStyle.Center;
qrOptions.BorderDashStyle = DevExpress.Docs.Barcode.BorderDashStyle.DashDot;
qrOptions.BorderWidth = 2f;
qrOptions.Dpi = 96;
qrOptions.ModuleSize = 3f;
qrOptions.RotationAngle = 0;
qrOptions.ShowText = true;
qrOptions.TextFont = new DXFont("Segoe UI", 12f);
qrOptions.CodeTextHorizontalAlignment = DXStringAlignment.Near;
qrOptions.CodeTextVerticalAlignment = DXStringAlignment.Near;

// QR Code-specific options.
qrOptions.CompactionMode = QRCodeCompactionMode.Byte;
qrOptions.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.Q;

using var output = new FileStream("BarCodeImage.png", FileMode.Create, FileAccess.Write);
using var generator = new BarcodeGenerator(qrOptions);
generator.Export("https://www.devexpress.com", output, DXImageFormat.Png);

Next Steps

See Also