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
-
size={
value } — Sets the size of the barcode -
datamatrixSize={[
row ,col ]} — Specifies the size to use for the barcode -
quietZone={
quietZoneSize } — Specifies to draw a quiet zone around the barcode -
tilde={
accept } — Modifies the use of the tilde character ~ -
acceptECI={
accept } — Specifies to accepts the ECI codes -
fnc1={
fnc1Type } — Transforms your barcode in GS1 or AIM standard -
encoding={
encoding } — Sets a specific encoding -
macro={
macro } — Specifies to prepend and append values to your data
BakeryBarcode2D's Methods
-
scaleX={
scaleX } — Sets the scaling X for the barcode -
scaleY={
scaleY } — Sets the scaling Y for the barcode
BakeryBarcode's Methods
-
text={
text } — Analyzes atext message to draw afterwards -
scale={
scale } — Sets the scale of the barcode -
foregroundColor={
color } — Sets the color of the bars -
backgroundColor={
color } — Sets the color of the spaces -
offsetX={
value } — Sets the X offset -
offsetY={
value } — Sets the Y offset
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 barcodeDescriptionThe 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 isBakeryDatamatrix.Size.Square . -
datamatrixSize={[
row ,col ]} — Specifies the size to use for the barcodeDescriptionBarcode 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 barcodeDescriptionGets if the quiet zone will be drawn. -
tilde={
accept } — Modifies the use of the tilde character ~DescriptionBy settingtrue 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 methodfnc1={} and drop the first ~F from your data. -
acceptECI={
accept } — Specifies to accepts the ECI codesDescriptionBy settingtrue 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 standardDescriptionThis 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 ontilde={} .
BakeryDatamatrix.Fnc1.Aim : The code will follow the AIM standard.
The default value isBakeryDatamatrix.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 methodfnc1={} and drop the first ~F from your data. -
encoding={
encoding } — Sets a specific encodingDescriptionYou 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 isBakeryDatamatrix.Encoding.Unknown . -
macro={
macro } — Specifies to prepend and append values to your dataDescriptionThe 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 isBakeryDatamatrix.Macro.None .
-
scaleX={
scaleX } — Sets the scaling X for the barcodeDescriptionThe 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 barcodeDescriptionThe height in pixel of one module.
The default value is 1.
Note that this method is protected.
-
text={
text } — Analyzes atext message to draw afterwardsDescriptionThe data you pass to thetext 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 barcodeDescriptionThe barcode will bex times bigger. Then a pixel will bex byx for its size. -
foregroundColor={
color } — Sets the color of the barsDescriptionSets the color of the bars of the barcode. By default, the color is black. This argument can be aBakeryColor class or any other argument thatBakeryColor can accept in its constructor. -
backgroundColor={
color } — Sets the color of the spacesDescriptionSets the color of the spaces of the barcode. By default, the color is white. This argument can be aBakeryColor class or any other argument thatBakeryColor can accept in its constructor. -
offsetX={
value } — Sets the X offsetDescriptionSpecifies the X offset of the barcode in pixels multiplied by the scale. -
offsetY={
value } — Sets the Y offsetDescriptionSpecifies the Y offset of the barcode in pixels multiplied by the scale.