Matrix 2 of 5
- 2 minutes to read
Matrix 2 of 5 is a linear numeric barcode. The symbology encodes all information in bars, while spaces have a fixed width and act as separators. Matrix 2 of 5 is used for warehouse sorting, photo finishing, and airline ticket marking.
Examples
Configure Barcode Settings (Matrix2of5Options)
Use the Matrix2of5Options class to configure Matrix 2 of 5 barcode settings.
The following code snippet creates the Matrix 2 of 5 barcode and specifies its settings:

using DevExpress.Docs.Barcode;
using DevExpress.Drawing;
using System.Drawing;
var mat2of5Options = new Matrix2of5Options();
mat2of5Options.CalculateChecksum = true;
mat2of5Options.WideNarrowRatio = 3;
mat2of5Options.BackColor = Color.LightGray;
mat2of5Options.ShowText = false;
mat2of5Options.Padding = new Padding(5);
mat2of5Options.BorderWidth = 1;
mat2of5Options.BorderColor = Color.Blue;
using var mat2of5OptionsStream = new FileStream(Path.Combine(outDir, "barcode_symbology_matrix_2of5.png"), FileMode.Create, FileAccess.Write);
using var mat2of5OptionsGenerator = new BarcodeGenerator(mat2of5Options);
mat2of5OptionsGenerator.Export("12345670", mat2of5OptionsStream, DXImageFormat.Png);
Configure Barcode Settings (Fluent API)
Use the Matrix2of5OptionsBuilder class to configure Matrix 2 of 5 barcode settings with Fluent API.
The following code snippet creates the Matrix 2 of 5 barcode and specifies its settings:

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