Back to Devexpress

QRCodeGenerator.CompactionMode Property

corelibraries-devexpress-dot-xtraprinting-dot-barcode-dot-qrcodegenerator.md

latest3.6 KB
Original Source

QRCodeGenerator.CompactionMode Property

Gets or sets whether numeric, alphanumeric or byte mode should be used to encode the barcode’s data.

Namespace : DevExpress.XtraPrinting.BarCode

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
[DefaultValue(QRCodeCompactionMode.AlphaNumeric)]
public virtual QRCodeCompactionMode CompactionMode { get; set; }
vb
<DefaultValue(QRCodeCompactionMode.AlphaNumeric)>
Public Overridable Property CompactionMode As QRCodeCompactionMode

Property Value

TypeDefaultDescription
QRCodeCompactionModeAlphaNumeric

A QRCodeCompactionMode enumeration value.

|

Available values:

NameDescription
Numeric

Numeric data is encoded. Max. 7,089 characters.

| | AlphaNumeric |

A combination of alphabetic and numeric characters is encoded. Max. 4,296 characters.

| | Byte |

Binary data is encoded. Max. 2,953 bytes.

|

Remarks

If the data encoded in numeric or alphanumeric mode contains invalid characters for the QR Code barcode, switch to byte mode to interpret the data as a sequence of bytes and use this sequence to encode the barcode.

Set the barcode’s CompactionMode property to Byte to enable byte mode. To specify binary data to encode the barcode, do one of the following:

  • Transform the data into a sequence of bytes and assign the sequence to the barcode’s BinaryData property.
  • Assign the data to the barcode’s Text property to automatically use UTF-8 to convert the data into a sequence of bytes.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CompactionMode property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-add-a-bar-code-to-a-report/CS/Form1.cs#L488

csharp
// Adjust the properties specific to the bar code type.
((QRCodeGenerator)barCode.Symbology).CompactionMode = QRCodeCompactionMode.AlphaNumeric;
((QRCodeGenerator)barCode.Symbology).ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;

See Also

QR Code

QRCodeGenerator Class

QRCodeGenerator Members

DevExpress.XtraPrinting.BarCode Namespace