Manual - QRCode
Introduction
QRCode 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 number of data to be encoded and the chosen error correction level. You can force the barcode to be rendered a specific size as long as there is enough room to encode the data.
You can enter ECI mode with the function acceptECI={}.
This class inherits the BakeryBarcode2D class.
Example
Methods
BakeryQrcode's Methods
-
errorLevel={
level } — Sets the error correction level of the barcode -
size={
value } — Sets the size of the barcode -
acceptECI={
accept } — Specifies to accepts the ECI codes -
quietZone={
quietZone } — Specifies to draw a quiet zone around the barcode -
mirror={
mirror } — Specifies to draw the barcode in mirror -
mask={
mask } — Specifies a mask to use instead of calculating one -
qrsize={[
qrSize ,qrMicro ]} — Specifies the size to use for the barcode
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 { BakeryQrcode } from '@barcode-bakery/barcode-react/qrcode';
export default function Home() {
const colorBlack = new BakeryColor(0, 0, 0);
const colorWhite = new BakeryColor(255, 255, 255);
return <BakeryQrcode
scale={2}
foregroundColor={colorBlack}
backgroundColor={colorWhite}
text='QRCode'
>;
}
Method explanations
-
errorLevel={
level } — Sets the error correction level of the barcodeDescriptionThis is the error correction level percentage before drawing the barcode.
The level must be an integer 0 to 3, or the corresponding letter L, M, Q, H.
The error level can recover respectively, approximately 7%, 15%, 25%, and 30%.
The default value is 1 (M). -
size={
value } — Sets the size of the barcodeDescriptionThe size of the final barcode will be decided automatically depending on the data you give and the error correction level percentage you have chosen, unless you specify it with the methodqrsize={} .
You can specify different values to this method to get a different code. There are the possible values:
BakeryQrcode.Size.Smallest : The code will be the smallest possible
BakeryQrcode.Size.Micros : The code will be in Micro mode
BakeryQrcode.Size.Full : The code will be in Full mode
The default value isBakeryQrcode.Size.Full . -
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. -
quietZone={
quietZone } — Specifies to draw a quiet zone around the barcodeDescriptionTo be read correctly, the QRCode must have a quiet zone around the image. You can, however, turn this off.
The default value is true. -
mirror={
mirror } — Specifies to draw the barcode in mirrorDescriptionIt is possible to read the barcode in mirror mode. If you set this variable totrue , the barcode will be drawn in mirror.
The default value is false. -
mask={
mask } — Specifies a mask to use instead of calculating oneDescriptionQRCode calculates 8 different masks before drawing the code. A mask allows changing the appearance of the barcode in order to make it more readable for a barcode reader. Mathematical operations are executed on every mask to verify which one would fit the best. Those operations are highly CPU consuming. If the generation speed is important for you, you may want to consider forcing a specific mask. Note that your barcode may become hard to read or unreadable.
If your barcode is a Micro, the validmask are 0 to 3.
If your barcode is a Full, the validmask are 0 to 7.
If you set -1, the mask is selected automatically.
The default value is -1. -
qrsize={[
qrSize ,qrMicro ]} — 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.
The first argument is the barcode version, and the second indicates if you want a Micro mode.
IfqrMicro is set totrue , the validqrSize are 1 to 4.
IfqrMicro is set tofalse , the validqrSize are 1 to 40.
If you set -1, the barcode size will be picked automatically. The second argument doesn't matter in that case; if you want to have a Micro or a Full barcode, see the methodsize={} .
The default value is -1.
-
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.