Manual - DataMatrix

Introduction

Datamatrix code comes from the 2D barcode family. You can encode a large amount of information within a single barcode.
All the ASCII characters from 0 to 255 are supported. The barcode size will be determined by the amount of data to be encoded. The error correction level is automatically chosen.
You can enter into ECI mode with the function acceptECI={}.

This class inherits the BakeryBarcode2D class.

Example

Methods

BakeryDatamatrix's Methods

BakeryBarcode2D's Methods

BakeryBarcode's Methods

Code Example

import { BakeryColor, BakeryFont } from '@barcode-bakery/barcode-react';
import { BakeryDatamatrix } from '@barcode-bakery/barcode-react/datamatrix';

export default function Home() {
  const colorBlack = new BakeryColor(0, 0, 0);
  const colorWhite = new BakeryColor(255, 255, 255);

  return <BakeryDatamatrix
    scale={2}
    foregroundColor={colorBlack}
    backgroundColor={colorWhite}
    text='Datamatrix'
  >;
}

Method explanations

  • size={value} — Sets the size of the barcode
    Description
    The size of the final barcode will be decided automatically depending on the data you give.
    You can, however, specify different values to this method to get a different code. There are the possible values:
    - BakeryDatamatrix.Size.Smallest : The code will be the smallest possible
    - BakeryDatamatrix.Size.Square : The code will be a square
    - BakeryDatamatrix.Size.Rectangle : The code will be a rectangle
    The default value is BakeryDatamatrix.Size.Square.
  • datamatrixSize={[row, col]} — Specifies the size to use for the barcode
    Description
    Barcode Bakery will pick the smallest barcode size based on the information you provide.
    If you wish to have a specific size, you can force the size with this method.
    You must specify a valid size or this method will raise an exception.
    The default value is -1.
  • quietZone={quietZoneSize} — Specifies to draw a quiet zone around the barcode
    Description
    Gets if the quiet zone will be drawn.
  • tilde={accept} — Modifies the use of the tilde character ~
    Description
    By setting true in this argument, the tilde characters (ASCII 126 ~) will be processed as special characters. These are the special characters you can write.
    - ~~ : Writes a simple tilde
    - ~F : Writes the FNC1 character
    The default value is false.
    Please note that it is possible to use ~F as the first character of your data, BUT it is possible that the automatic encoding changes the meaning of your barcode by not starting your data with a FNC1. So we recommend that you use the method fnc1={} and drop the first ~F from your data.
  • acceptECI={accept} — Specifies to accepts the ECI codes
    Description
    By setting true in this argument, the backslash characters (ASCII 92 \) will be processed as special characters. These are the special characters you can write.
    - \\ : Writes a simple backslash
    - \xxxxxx : Writes the ECI xxxxxx character with x representing an integer from 0 to 9
    The default value is false.
  • fnc1={fnc1Type} — Transforms your barcode in GS1 or AIM standard
    Description
    This method will transform your barcode to accept FNC1 to be GS1 standard or AIM standard.
    BakeryDatamatrix.Fnc1.None : The code will not follow any standards.
    BakeryDatamatrix.Fnc1.Gs1 : The code will follow the GS1 standard. Separate GS1 identifiers by ~F. Don't forget to turn on tilde={}.
    BakeryDatamatrix.Fnc1.Aim : The code will follow the AIM standard.
    The default value is BakeryDatamatrix.Fnc1.None.
    Please note that it is possible to use ~F as the first character of your data, BUT it is possible that the automatic encoding changes the meaning of your barcode by not starting your data with a FNC1. So we recommend that you use the method fnc1={} and drop the first ~F from your data.
  • encoding={encoding} — Sets a specific encoding
    Description
    You can force an encoding to be used for different reasons. Some readers are not able to read a specific encoding, so you can force the ASCII mode.
    Note that by forcing the encoding, you may not get an efficient result. Furthermore, some characters cannot be represented in some encodings.
    See the technical information page for more information about the encodings.
    - BakeryDatamatrix.Encoding.Unknown : No specific encoding is selected
    - BakeryDatamatrix.Encoding.Ascii : ASCII and extended ASCII (low compression)
    - BakeryDatamatrix.Encoding.C40 : C40 encoding (capital letters)
    - BakeryDatamatrix.Encoding.Text : TEXT encoding (lowercase letters)
    - BakeryDatamatrix.Encoding.X12 : X12 encoding (capital letters and numbers)
    - BakeryDatamatrix.Encoding.Edifact : Edifact encoding
    - BakeryDatamatrix.Encoding.Base256 : Binary encoding
    The default value is BakeryDatamatrix.Encoding.Unknown.
  • macro={macro} — Specifies to prepend and append values to your data
    Description
    The macro has been defined to make your data and barcode smaller in size. Use this method to prepend and append predefined data in your barcode when read.
    - BakeryDatamatrix.Macro.None : Your data will appear raw. No prefix or suffix.
    - BakeryDatamatrix.Macro._05 : Prefix: [)>RS05GS - Suffix: RSEoT
    - BakeryDatamatrix.Macro._06 : Prefix: [)>RS06GS - Suffix: RSEoT
    The default value is BakeryDatamatrix.Macro.None.
  • scaleX={scaleX} — Sets the scaling X for the barcode
    Description
    The width in pixel of one module.
    The default value is 1.
    Note that this method is protected.
  • scaleY={scaleY} — Sets the scaling Y for the barcode
    Description
    The height in pixel of one module.
    The default value is 1.
    Note that this method is protected.
  • text={text} — Analyzes a text message to draw afterwards
    Description
    The data you pass to the text argument must be supported by the type of barcode you use.
    Check each barcode's introduction section to obtain more information on how to use this method within each symbology.
  • scale={scale} — Sets the scale of the barcode
    Description
    The barcode will be x times bigger. Then a pixel will be x by x for its size.
  • foregroundColor={color} — Sets the color of the bars
    Description
    Sets the color of the bars of the barcode. By default, the color is black. This argument can be a BakeryColor class or any other argument that BakeryColor can accept in its constructor.
  • backgroundColor={color} — Sets the color of the spaces
    Description
    Sets the color of the spaces of the barcode. By default, the color is white. This argument can be a BakeryColor class or any other argument that BakeryColor can accept in its constructor.
  • offsetX={value} — Sets the X offset
    Description
    Specifies the X offset of the barcode in pixels multiplied by the scale.
  • offsetY={value} — Sets the Y offset
    Description
    Specifies the Y offset of the barcode in pixels multiplied by the scale.