Barcode2D Class
Represents a generated two-dimensional barcode (Data Matrix, PDF417 or Aztec) as a boolean matrix of modules.
public sealed class Barcode2DRemarks
A text made of ASCII characters only (U+0000 to U+007F) is encoded as it is. Another text is encoded as UTF-8, preceded by the ECI designator of UTF-8 (assignment number 26), so that readers do not decode its bytes with the default character set of the symbology. Binary data is encoded as it is, without an ECI designator.
The modules are square. The rows of a PDF417 symbol are taller than its modules are wide: each row of the symbol is Pdf417Options.RowHeight rows of the matrix.
Properties
| Name | Description |
|---|---|
| Height | Gets the height (number of rows), quiet zone excluded. |
| Type | Gets the type of barcode. |
| Width | Gets the width (number of columns), quiet zone excluded. |
Height
Barcode2D.csType
Barcode2D.csWidth
Barcode2D.csIndexers
| Name | Description |
|---|---|
| this[int, int] | Gets whether the module at the specified position is dark. |
this[int, int]
Barcode2D.csMethods
| Name | Description |
|---|---|
| CreateAztec(ReadOnlySpan<byte>, AztecOptions?) | Creates an Aztec symbol from the specified binary data. |
| CreateAztec(string, AztecOptions?) | Creates an Aztec symbol from the specified text. |
| CreateDataMatrix(ReadOnlySpan<byte>, DataMatrixOptions?) | Creates a Data Matrix (ECC 200) symbol from the specified binary data. |
| CreateDataMatrix(string, DataMatrixOptions?) | Creates a Data Matrix (ECC 200) symbol from the specified text. |
| CreateGs1DataMatrix(ReadOnlySpan<Gs1Element>) | Creates a GS1 Data Matrix symbol from GS1 element strings. |
| CreateGs1DataMatrix(ReadOnlySpan<Gs1Element>, DataMatrixOptions?) | Creates a GS1 Data Matrix symbol from GS1 element strings. |
| CreatePdf417(ReadOnlySpan<byte>, Pdf417Options?) | Creates a PDF417 symbol from the specified binary data. |
| CreatePdf417(string, Pdf417Options?) | Creates a PDF417 symbol from the specified text. |
CreateAztec overloads
CreateAztec(ReadOnlySpan<byte>, AztecOptions?)
Barcode2D.csCreates an Aztec symbol from the specified binary data.
public static Barcode2D CreateAztec(ReadOnlySpan<byte> data, AztecOptions? options = null)Parameters
dataReadOnlySpan<byte>- The bytes to encode.
optionsAztecOptions?- The options, or
nullfor the defaults: the smallest compact or full-range symbol that holds the data with 23% of error correction.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentExceptiondatais empty, orAztecOptions.Layersis greater than 4 for a compact symbol.InvalidOperationException- The data does not fit in the largest allowed size.
CreateAztec(string, AztecOptions?)
Barcode2D.csCreates an Aztec symbol from the specified text.
public static Barcode2D CreateAztec(string data, AztecOptions? options = null)Parameters
datastring- The text to encode.
optionsAztecOptions?- The options, or
nullfor the defaults: the smallest compact or full-range symbol that holds the data with 23% of error correction.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentNullExceptiondataisnull.ArgumentExceptiondatais empty, orAztecOptions.Layersis greater than 4 for a compact symbol.InvalidOperationException- The data does not fit in the largest allowed size.
CreateDataMatrix overloads
CreateDataMatrix(ReadOnlySpan<byte>, DataMatrixOptions?)
Barcode2D.csCreates a Data Matrix (ECC 200) symbol from the specified binary data.
public static Barcode2D CreateDataMatrix(ReadOnlySpan<byte> data, DataMatrixOptions? options = null)Parameters
dataReadOnlySpan<byte>- The bytes to encode.
optionsDataMatrixOptions?- The options, or
nullfor the defaults: the smallest square symbol that holds the data.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentExceptiondatais empty, or no Data Matrix size satisfies the constraints ofoptions.InvalidOperationException- The data does not fit in the largest allowed size.
CreateDataMatrix(string, DataMatrixOptions?)
Barcode2D.csCreates a Data Matrix (ECC 200) symbol from the specified text.
public static Barcode2D CreateDataMatrix(string data, DataMatrixOptions? options = null)Parameters
datastring- The text to encode.
optionsDataMatrixOptions?- The options, or
nullfor the defaults: the smallest square symbol that holds the data.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentNullExceptiondataisnull.ArgumentExceptiondatais empty, or no Data Matrix size satisfies the constraints ofoptions.InvalidOperationException- The data does not fit in the largest allowed size.
CreateGs1DataMatrix overloads
CreateGs1DataMatrix(ReadOnlySpan<Gs1Element>)
Barcode2D.csCreates a GS1 Data Matrix symbol from GS1 element strings.
public static Barcode2D CreateGs1DataMatrix(params scoped ReadOnlySpan<Gs1Element> elements)Parameters
elementsReadOnlySpan<Gs1Element>- The element strings, in the order they are encoded.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentExceptionelementsis empty or containsnull.InvalidOperationException- The data does not fit in the largest Data Matrix symbol.
Remarks
The symbol starts with the FNC1 function character that identifies GS1 Data Matrix, and a FNC1 separator follows each element whose application identifier does not have a predefined length, except the last one. A reader returns the data with the separators as the ASCII group separator character (U+001D) and the symbology identifier ]d2.
CreateGs1DataMatrix(ReadOnlySpan<Gs1Element>, DataMatrixOptions?)
Barcode2D.csCreates a GS1 Data Matrix symbol from GS1 element strings.
public static Barcode2D CreateGs1DataMatrix(ReadOnlySpan<Gs1Element> elements, DataMatrixOptions? options)Parameters
elementsReadOnlySpan<Gs1Element>- The element strings, in the order they are encoded.
optionsDataMatrixOptions?- The options, or
nullfor the defaults: the smallest square symbol that holds the data.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentExceptionelementsis empty or containsnull, or no Data Matrix size satisfies the constraints ofoptions.InvalidOperationException- The data does not fit in the largest allowed size.
Remarks
The symbol starts with the FNC1 function character that identifies GS1 Data Matrix, and a FNC1 separator follows each element whose application identifier does not have a predefined length, except the last one. A reader returns the data with the separators as the ASCII group separator character (U+001D) and the symbology identifier ]d2.
CreatePdf417 overloads
CreatePdf417(ReadOnlySpan<byte>, Pdf417Options?)
Barcode2D.csCreates a PDF417 symbol from the specified binary data.
public static Barcode2D CreatePdf417(ReadOnlySpan<byte> data, Pdf417Options? options = null)Parameters
dataReadOnlySpan<byte>- The bytes to encode.
optionsPdf417Options?- The options, or
nullfor the defaults: the error correction level recommended for the data length, and a number of columns chosen for the data.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentExceptiondatais empty.InvalidOperationException- The data does not fit in a PDF417 symbol with the constraints of
options.
CreatePdf417(string, Pdf417Options?)
Barcode2D.csCreates a PDF417 symbol from the specified text.
public static Barcode2D CreatePdf417(string data, Pdf417Options? options = null)Parameters
datastring- The text to encode.
optionsPdf417Options?- The options, or
nullfor the defaults: the error correction level recommended for the data length, and a number of columns chosen for the data.
Returns
Barcode2D A new Barcode2D instance.
Exceptions
ArgumentNullExceptiondataisnull.ArgumentExceptiondatais empty.InvalidOperationException- The data does not fit in a PDF417 symbol with the constraints of
options.