xtrareports-405176-feature-guide-to-devexpress-reports-use-report-controls-use-bar-codes-micro-qr-code.md
A Micro QR Code is a two-dimensional code. It is a more compact version of a standard QR code: a Micro QR Code can encode up to 35 numeric characters or 21 alphanumeric characters, enough to store a product ID or a short URL. In comparison, a standard QR code can contain up to 7,089 characters.
Micro QR Codes are often used in industries such as electronics, medical devices, and retail, where space-efficient labeling is essential.
Refer to the following article for more information: Micro QR Code.
| Version | Size (Modules) | Numeric Capacity | Alphanumeric Capacity | Binary Capacity (Bytes) | Error Correction Levels | Use Case |
|---|---|---|---|---|---|---|
| M1 | 11×11 | 5 characters | N/A | N/A | Detection only (D) | Ideal for minimal numeric data in space-constrained environments. |
| M2 | 13×13 | 10 characters | 6 characters | 4 bytes | Level L (7%) | Small data capacity with basic error correction in tight spaces. |
| M3 | 15×15 | 23 characters | 14 characters | 9 bytes | Level L (7%), Level M (15%) | Moderate data capacity with more flexible error correction and space requirements. |
| M4 | 17×17 | 35 characters | 21 characters | 15 bytes | Level L (7%), Level M (15%), Level Q (25%) | Higher data capacity with flexible error correction while maintaining a compact size. |
To add a barcode to a report, follow these steps:
Drag the XRBarCode item from the DX.25.2: Report Controls tab and drop it onto the report.
Set the XRBarCode control’s Symbology property to Micro QR Code (an object of the MicroQRCodeGenerator type).
Specify common barcode properties and properties specific to the Micro QR Code.
CompactionModeGets or sets whether the barcode contains a number, an alphanumeric string, or a byte array.ErrorCorrectionLevelSpecifies the amount of redundancy built into the Micro QR code to compensate for calculation errors.IncludeQuietZoneGets or sets whether to add a blank space around the Micro QR code to help separate the Micro QR code from neighboring elements.VersionGets or sets the barcode’s version.
The following code snippet generates a Micro QR Code barcode and specifies its properties:
View Example: How to add a barcode to a report
using System.Collections.Generic;
using System.Drawing.Printing;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
public XRBarCode CreateMicroQRCodeBarCode(string BarCodeText) {
// Create a barcode control.
XRBarCode barCode = new XRBarCode();
// Set the barcode's type to QRCode.
barCode.Symbology = new MicroQRCodeGenerator();
// Adjust the barcode's main properties.
barCode.Text = BarCodeText;
barCode.Width = 150;
barCode.Height = 150;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
// barcode.Module = 3;
// Adjust the properties specific to the barcode type.
((MicroQRCodeGenerator)barCode.Symbology).CompactionMode = MicroQRCodeCompactionMode.AlphaNumeric;
((MicroQRCodeGenerator)barCode.Symbology).ErrorCorrectionLevel = MicroQRCodeErrorCorrectionLevel.L;
((MicroQRCodeGenerator)barCode.Symbology).Version = MicroQRCodeVersion.AutoVersion;
return barCode;
}
Imports System.Collections.Generic
Imports System.Drawing.Printing
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraReports.UI
Public Function CreateMicroQRCodeBarCode(ByVal BarCodeText As String) As XRBarCode
' Create a barcode control.
Dim barCode As New XRBarCode()
' Set the barcode's type to QRCode.
barCode.Symbology = New MicroQRCodeGenerator()
' Adjust the barcode's main properties.
barCode.Text = BarCodeText
barCode.Width = 150
barCode.Height = 150
' If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = True
' barcode.Module = 3;
' Adjust the properties specific to the barcode type.
CType(barCode.Symbology, MicroQRCodeGenerator).CompactionMode = MicroQRCodeCompactionMode.AlphaNumeric
CType(barCode.Symbology, MicroQRCodeGenerator).ErrorCorrectionLevel = MicroQRCodeErrorCorrectionLevel.L
CType(barCode.Symbology, MicroQRCodeGenerator).Version = MicroQRCodeVersion.AutoVersion
Return barCode
End Function
The code example below shows how to create a report with a Micro QR Code barcode:
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
//...
var barCode = MicroQRCodeGenerator("0123-ABCD");
var report = new XtraReport() {
Bands = {
new DetailBand() {
Controls = { barCode }
}
}
};
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraReports.UI
'...
Private barCode = MicroQRCodeGenerator("0123-ABCD")
Dim report As New XtraReport()
Dim band = New DetailBand()
band.Controls.Add(barCode)