The component is used to create the QR Code barcode symbols. It's defined in the pQRCode unit.
A QR Code is a two-dimensional matrix symbology, readable by QR scanners, mobile phones with a camera, and smartphones. The code consists of black modules arranged in a square pattern on white background. It has position detection patterns on three of its four corners. The information encoded can be text, URL or other data.
Common in Japan, where it was created by Toyota subsidiary Denso-Wave in 1994, the QR Code is one of the most popular types of two-dimensional barcodes. Although initially used for tracking parts in vehicle manufacturing, QR Codes are now used in a much broader context, including both commercial tracking applications and convenience-oriented applications aimed at mobile phone users.
QR is the abbreviation for Quick Response, as the creator intended the code to allow its contents to be decoded at high speed.
There are four user-selectable levels of error correction, as shown in following table, offering the capability of recovery from the amounts of damage in the table:
Values of ECCLevel property | ECC levels | Recevory capacities (%) (approx.) |
---|---|---|
elLowest | L | 7 |
elMedium | M | 15 |
elQuality | Q | 25 |
elHighest | H | 30 |
You can use the ECCLevel property to specify the error correction code level for a QR Code symbol. It can be one of these values: elLowest, elMedium, elQuality, and elHighest, corresponding to the error checking and correcting levels L, M, Q, and H. These values are defined in the pRCode unit.
If the ECCLevelUpgrade property is set to true, the highest error correction code level that can be accommodated by current symbol size will by used for creating more robust symbols. Note, the new level is always no lower than the level specified by the ECCLevel property, and the symbol size will not be increased, it may be determined depending on the length of barcode text, and the error correction code level specified by the ECCLevel property (see also the "Symbol sizes" section below). In other words, only the remaining capacity in current symbol size will be used to upgrade the error correction code level. The property CurrentECCLevel can be used to get the factual error correction code level.
There are forty sizes of QR Code symbol. referred to as version 1 to 40, in increasing order of data capacity. You can use the MinVersion and the MaxVersion properties to specifiy the minimum and maximum sizes for a QR Code symbol. They can be one of values from 1 to 40 (defined in the pQRCode unit), corresponding to the versions 1 to 40. The smallest symbol size that accommodates the barcode text will be automatically selected between minimum and maximum symbol sizes. The CurrentVersion property can be used to get the factual symbol size.
These symbol sizes and the maximum data capacity of each version are listed in following table:
Version | Symbol size (modules) | ECC level | Data capacities | |||
---|---|---|---|---|---|---|
Numeric mode | Alphanumeric mode | Byte mode | Kanji mode | |||
1 | 21 * 21 | L | 41 | 25 | 17 | 10 |
M | 34 | 20 | 14 | 8 | ||
Q | 27 | 16 | 11 | 7 | ||
H | 17 | 10 | 7 | 4 | ||
2 | 25 * 25 | L | 77 | 47 | 32 | 20 |
M | 63 | 38 | 26 | 16 | ||
Q | 48 | 29 | 20 | 12 | ||
H | 34 | 20 | 14 | 8 | ||
3 | 29 * 29 | L | 127 | 77 | 53 | 32 |
M | 101 | 61 | 42 | 26 | ||
Q | 77 | 47 | 32 | 20 | ||
H | 58 | 35 | 24 | 15 | ||
4 | 33 * 33 | L | 187 | 114 | 78 | 48 |
M | 149 | 90 | 62 | 38 | ||
Q | 111 | 67 | 46 | 28 | ||
H | 82 | 50 | 34 | 21 | ||
5 | 37 * 37 | L | 255 | 154 | 106 | 65 |
M | 202 | 122 | 84 | 52 | ||
Q | 144 | 87 | 60 | 37 | ||
H | 106 | 64 | 44 | 27 | ||
6 | 41 * 41 | L | 322 | 195 | 134 | 82 |
M | 255 | 154 | 106 | 65 | ||
Q | 178 | 108 | 74 | 45 | ||
H | 139 | 84 | 58 | 36 | ||
7 | 45 * 45 | L | 370 | 224 | 154 | 95 |
M | 293 | 178 | 122 | 75 | ||
Q | 207 | 125 | 86 | 53 | ||
H | 154 | 93 | 64 | 39 | ||
8 | 49 * 49 | L | 461 | 279 | 192 | 118 |
M | 365 | 221 | 152 | 93 | ||
Q | 259 | 157 | 108 | 66 | ||
H | 202 | 122 | 84 | 52 | ||
9 | 53 * 53 | L | 522 | 335 | 230 | 141 |
M | 432 | 262 | 180 | 111 | ||
Q | 312 | 189 | 130 | 80 | ||
H | 235 | 143 | 98 | 60 | ||
10 | 57 * 57 | L | 652 | 395 | 271 | 167 |
M | 513 | 311 | 213 | 131 | ||
Q | 364 | 221 | 151 | 93 | ||
H | 288 | 174 | 119 | 74 | ||
11 | 61 * 61 | L | 772 | 468 | 321 | 198 |
M | 604 | 366 | 251 | 155 | ||
Q | 427 | 259 | 177 | 109 | ||
H | 331 | 200 | 137 | 85 | ||
12 | 65 * 65 | L | 883 | 535 | 367 | 226 |
M | 691 | 419 | 287 | 177 | ||
Q | 489 | 296 | 203 | 125 | ||
H | 374 | 227 | 155 | 96 | ||
13 | 69 * 69 | L | 1022 | 619 | 425 | 262 |
M | 796 | 483 | 331 | 204 | ||
Q | 580 | 352 | 241 | 149 | ||
H | 427 | 259 | 177 | 109 | ||
14 | 73 * 73 | L | 1101 | 667 | 458 | 282 |
M | 871 | 528 | 362 | 223 | ||
Q | 621 | 376 | 258 | 159 | ||
H | 468 | 283 | 194 | 120 | ||
15 | 77 * 77 | L | 1250 | 758 | 520 | 320 |
M | 991 | 600 | 412 | 254 | ||
Q | 703 | 426 | 292 | 180 | ||
H | 530 | 321 | 220 | 136 | ||
16 | 81 * 81 | L | 1408 | 854 | 586 | 361 |
M | 1082 | 656 | 450 | 277 | ||
Q | 775 | 470 | 322 | 198 | ||
H | 602 | 365 | 250 | 154 | ||
17 | 85 * 85 | L | 1548 | 938 | 644 | 397 |
M | 1212 | 734 | 504 | 310 | ||
Q | 876 | 531 | 364 | 224 | ||
H | 674 | 408 | 280 | 173 | ||
18 | 89 * 89 | L | 1725 | 1046 | 718 | 442 |
M | 1346 | 816 | 560 | 345 | ||
Q | 948 | 574 | 394 | 243 | ||
H | 746 | 452 | 310 | 191 | ||
19 | 93 * 93 | L | 1903 | 1153 | 792 | 488 |
M | 1500 | 909 | 624 | 384 | ||
Q | 1063 | 644 | 442 | 272 | ||
H | 813 | 493 | 338 | 208 | ||
20 | 97 * 97 | L | 2061 | 1249 | 858 | 528 |
M | 1600 | 970 | 666 | 410 | ||
Q | 1159 | 702 | 482 | 297 | ||
H | 919 | 557 | 382 | 235 | ||
21 | 101 * 101 | L | 2232 | 1352 | 929 | 572 |
M | 1708 | 1035 | 711 | 438 | ||
Q | 1224 | 742 | 509 | 314 | ||
H | 969 | 587 | 403 | 248 | ||
22 | 105 * 105 | L | 2409 | 1460 | 1003 | 618 |
M | 1872 | 1134 | 779 | 480 | ||
Q | 1358 | 823 | 565 | 348 | ||
H | 1056 | 640 | 439 | 270 | ||
23 | 109 * 109 | L | 2620 | 1588 | 1091 | 672 |
M | 2059 | 1248 | 857 | 528 | ||
Q | 1468 | 890 | 611 | 376 | ||
H | 1108 | 672 | 461 | 284 | ||
24 | 113 * 113 | L | 2812 | 1704 | 1171 | 721 |
M | 2188 | 1326 | 911 | 561 | ||
Q | 1588 | 963 | 661 | 407 | ||
H | 1228 | 744 | 511 | 315 | ||
25 | 117 * 117 | L | 3057 | 1853 | 1273 | 784 |
M | 2395 | 1451 | 997 | 614 | ||
Q | 1718 | 1041 | 715 | 440 | ||
H | 1286 | 779 | 535 | 330 | ||
26 | 121 * 121 | L | 3283 | 1990 | 1367 | 842 |
M | 2544 | 1542 | 1059 | 652 | ||
Q | 1804 | 1094 | 751 | 462 | ||
H | 1425 | 864 | 593 | 365 | ||
27 | 125 * 125 | L | 3517 | 2132 | 1465 | 902 |
M | 2701 | 1637 | 1125 | 692 | ||
Q | 1933 | 1172 | 805 | 496 | ||
H | 1501 | 910 | 625 | 385 | ||
28 | 129 * 129 | L | 3669 | 2223 | 1528 | 940 |
M | 2857 | 1732 | 1190 | 732 | ||
Q | 2085 | 1263 | 868 | 534 | ||
H | 1581 | 958 | 658 | 405 | ||
29 | 133 * 133 | L | 3909 | 2369 | 1628 | 1002 |
M | 3035 | 1839 | 1264 | 778 | ||
Q | 2181 | 1322 | 908 | 559 | ||
H | 1677 | 1016 | 698 | 430 | ||
30 | 137 * 137 | L | 4158 | 2520 | 1732 | 1066 |
M | 3289 | 1994 | 1370 | 843 | ||
Q | 2358 | 1429 | 982 | 604 | ||
H | 1782 | 1080 | 742 | 457 | ||
31 | 141 * 141 | L | 4417 | 2677 | 1840 | 1132 |
M | 3486 | 2113 | 1452 | 894 | ||
Q | 2473 | 1499 | 1030 | 634 | ||
H | 1897 | 1150 | 790 | 486 | ||
32 | 145 * 145 | L | 4686 | 2840 | 1952 | 1201 |
M | 3693 | 2238 | 1538 | 947 | ||
Q | 2670 | 1618 | 1112 | 684 | ||
H | 2022 | 1226 | 842 | 518 | ||
33 | 149 * 149 | L | 4965 | 3009 | 2068 | 1273 |
M | 3909 | 2369 | 1628 | 1002 | ||
Q | 2805 | 1700 | 1168 | 719 | ||
H | 2157 | 1307 | 898 | 553 | ||
34 | 153 * 153 | L | 5253 | 3183 | 2188 | 1347 |
M | 4134 | 2506 | 1722 | 1060 | ||
Q | 2949 | 1787 | 1228 | 756 | ||
H | 2301 | 1394 | 958 | 590 | ||
35 | 157 * 157 | L | 5529 | 3351 | 2303 | 1417 |
M | 4343 | 2632 | 1809 | 1113 | ||
Q | 3081 | 1867 | 1283 | 790 | ||
H | 2361 | 1431 | 983 | 605 | ||
36 | 161 * 161 | L | 5836 | 3537 | 2431 | 1496 |
M | 4588 | 2780 | 1911 | 1176 | ||
Q | 3244 | 1966 | 1351 | 832 | ||
H | 2524 | 1530 | 1051 | 647 | ||
37 | 165 * 165 | L | 6153 | 3729 | 2563 | 1577 |
M | 4775 | 2894 | 1989 | 1224 | ||
Q | 3417 | 2071 | 1423 | 876 | ||
H | 2625 | 1591 | 1093 | 673 | ||
38 | 169 * 169 | L | 6479 | 3927 | 2699 | 1661 |
M | 5039 | 3054 | 2099 | 1292 | ||
Q | 3599 | 2181 | 1499 | 923 | ||
H | 2735 | 1658 | 1139 | 701 | ||
39 | 173 * 173 | L | 6743 | 4087 | 2809 | 1729 |
M | 5313 | 3220 | 2213 | 1362 | ||
Q | 3791 | 2298 | 1579 | 972 | ||
H | 2927 | 1774 | 1219 | 750 | ||
40 | 177 * 177 | L | 7089 | 4296 | 2953 | 1817 |
M | 5596 | 3391 | 2331 | 1435 | ||
Q | 3993 | 2420 | 1663 | 1024 | ||
H | 3057 | 1852 | 1273 | 784 |
If the barcode text does not fill the maximum data capacity of the QR Code symbol, remaining data capacity of the symbol will be filled by using PAD characters. If the barcode text is so long that it cannot be encoded using the maximum symbol size specified by the MaxVersion property, an OnInvalidLength or OnInvalidDataLength (only for Delphi/C++ Builder 2009 or later) event will occur.
The minimum quiet zone is equal to 4 modules on all four sides. So the minimum values of LeadingQuietZone, TrailingQuietZone, TopQuietZone, and BottomQuietZone properties are equal to 4.
All 8-bit values can be encoded. The default interpretation shall be:
This interpretation corresponds to ECI 000003.
The FNC1 characters can be encoded for compatibility with some existing applications. In QR Code symbology, there are two mode FNC1 characters to identify symbols encoding messages formatted according to specific predefined industry or application specifications:
First position: FNC1 in this mode indicator identifies symbols encoding data formatted according to the GS1 Application Identifiers standard. For this purpose, it shall only be used once in a symbol and shall be placed at beginning of the barcode text, and after any ECI indicator block or structured append block (if exists).
The escape sequence "\t" or "\f" followed by an Application Identifier (2 or more digits), can be used to placed the FNC1 character in "First position" mode to barcode text. For example, the barcode symbol (01)00012345678905 can be represented using any one of following sequences:
\t0100012345678905
\f0100012345678905
Where the GS1 specifications call for the FNC1 character to be used as a data field separator (i.e. at the end of a variable-length data field), QR Code symbols shall use the GS character (byte value 29) to perform this function. In this case, any one of "\g", "\d", "\t", and "\f" escape sequences can be used to place the GS character to the barcode text. For example:
\t010001234567890521512\f2018
Second position: FNC1 in this mode indicator identifies symbols formatted in accordance with specific industry or application specifications previously agreed with AIM International. It is immediately followed by an application indicator assigned to identify the specification concerned by AIM International. For this purpose, it shall only be used once in a symbol and shall be placed at beginning of the barcode, and after any ECI indicator block or structured append block (if exists). An application indicator may take the form of any single Latin alphabetic character from the set "a" to "z" and "A" to "Z", or a two-digit number.
There are two ways to place a FNC1 character in "Second position" mode:
The escape sequence "\d" followed by an application indicator (single Latin alphabetic character from the set "a" to "z" and "A" to "Z", or a two-digit number) can be used to placed the FNC1 character in "Second position" mode to barcode text. For example:
\dA0001234567890
\d010001234567890
The escape sequence "\f[<AI>]" can be used to placed the FNC1 character in "Second position" mode to barcode text:
For example:
\f[A]0001234567890
\f[01]0001234567890
Where the application specifications call for the FNC1 character to be used as a data field separator, QR Code symbols shall use the GS character (byte value 29) to perform this function. In this case, any one of "\g", "\d", "\t", and "\f" escape sequences can be used to place the GS character to the barcode text. For example:
\dA0001234567890521512\g2018
Note, the "First position" and "Second position" are not used in a literal sense but is a historical reference to the position of the FNC1 symbol character in Code 128 symbols.
The ECI indicator blocks can be encoded for the standardized encoding of message interpretation information. The escape sequence "\e[<ECI_Number>]" can be used to place the ECI indicator block to barcode text. See also the "Extended Channel Interpretation (ECI)" section below.
The AllowEscape property should be set to true in order to place the FNC1 characters or the ECI indicator blocks.
If the AllowEscape property is set to true, following escape sequences are supported by the component, you can insert them to the barcode text:
\\: Insert a backslash to barcode text.
\f: Insert a FNC1 character to barcode text. There are three usages:
Insert a FNC1 character in "First position" mode to the barcode text. In this case, it shall only be used once in a symbol and shall be placed at beginning of the barcode text, and after any ECI indicator block or structured append block (if exists), followed by an Application Identifier (2 or more digits). For example:
\f0100012345678905
Insert a FNC1 character in "Second position" mode to the barcode text. In this case, it shall only be used once in a symbol and shall be placed at beginning of the barcode text, and after any ECI indicator block or structured append block (if exists), followed by an application indicator (single Latin alphabetic character from the set "a" to "z" and "A" to "Z", or a two-digit number), which is enclosed in square brackets. For example:
\f[01]00012345678905
Insert a GS character (ASCII value 29) as the data field separator to the barcode text. In this case, it can be placed anywhere but at beginning of the barcode text. For example:
\t010001234567890521512\f2018
See also the "Character set" section above.
\t: Insert a FNC1 character in "First position" mode to barcode text, or insert a GS character (ASCII value 29) as the data field separator to the barcode text. There are two usages:
Insert a FNC1 character in "First position" mode to the barcode text. It's completely equivalent to escape sequence "\f" that inserts the FNC1 character in "First position" mode. In this case, it shall only be used once in a symbol and shall be placed at beginning of the barcode text, and after any ECI indicator block or structured append block (if exists), followed by an Application Identifier (2 or more digits). For example:
\t0100012345678905
Insert a GS character (ASCII value 29) as the data field separator to the barcode text. It's completely equivalent to the escape sequence "\f" that inserts the FNC1 character as the data field separator. In this case, it can be placed anywhere but at beginning of the barcode text. For example:
\f010001234567890521512\t2018
See also the "Character set" section above.
\d: Insert a FNC1 character in "Second position" mode to barcode text, or insert a GS character (ASCII value 29) as the data field separator to the barcode text. There are two usages:
Insert a FNC1 character in "Second position" mode to the barcode text. It's completely equivalent to escape sequence "\f" that inserts the FNC1 character in "Second position" mode. In this case, it shall only be used once in a symbol and shall be placed at beginning of the barcode text, and after any ECI indicator block or structured append block (if exists), followed by an application indicator (single Latin alphabetic character from the set "a" to "z" and "A" to "Z", or a two-digit number). For example:
\d0100012345678905
Insert a GS character (ASCII value 29) as the data field separator to the barcode text. It's completely equivalent to the escape sequence "\f" that inserts the FNC1 character as the data field separator. In this case, it can be placed anywhere but at beginning of the barcode text. For example:
\f010001234567890521512\d2018
See also the "Character set" section above.
\g: Insert a GS character (ASCII value 29) to the barcode text. When FNC1 is used as a data field separator, it can be used instead of the FNC1 character. For example:
\f010001234567890521512\g2018
See also the "Character set" section above.
\e[<ECI_Number>]: Insert an ECI indicator block to barcode text. See also the "Extended Channel Interpretation (ECI)" section below.
\s[<Index>, <Amound>, <Parity>]: Insert a structured append block to barcode text in order to create the symbol in a structured append. See also the "Structured append" section below.
QR Code has four encoding modes as Numeric mode, Alphanumeric mode, Kanji mode and Byte mode respectively in decreasing order of encoding density. All 256 8-bits value are encoded by switching automatically between all 4 (the AllowKanjiMode property is set to true) or 3 (the Kanji mode will not be used if the AllowKanjiMode property is set to false) encoding modes. The character sets in each mode are listed in the following:
Numeric mode: Encodes data from the decimal digit set (0 to 9) (byte values 48 to 57).
Alphanumeric mode: Encodes data from a set of 45 characters, i.e. 10 numeric digits (0 to 9) (byte values 48 to 57), 26 alphabetic characters (A - Z) (byte values 65 to 90) , and 9 symbols (SP, $, %, *, +, -, ., /, :) (byte values 32, 36, 37, 42, 43, 45 to 47, 58 respectively).
Byte mode: All 8-bit values can be encoded.
Kanji mode: The Kanji mode efficiently encodes Kanji characters in accordance with the Shift JIS system based on JIS X 0208. The Shift JIS values are shifted from the JIS X 0208 values. JIS X 0208 gives details of the shift coded representation.
It may be possible to achieve a smaller symbol size by using the Kanji mode compaction rules when an appropriate sequence of byte values occurs in the data. You can set the AllowKanjiMode property to false in order to disable the Kanji mode.
The EncodePolicy property indicates how to use these encoding mode by the component. This property can be one of these values (defined in the pQRCode unit):
epMixingOptimal: All 256 8-bits values are encoded by switching automatically between all 4 (the AllowKanjiMode property is set to true) or 3 (the Kanji mode will not be used if the AllowKanjiMode property is set to false) encoding modes. The optimal combination of encoding modes will be used in order to minimize the symbol size.
epMixingQuick: All 256 8-bits values are encoded by switching automatically between all 4 (the AllowKanjiMode property is set to true) or 3 (the Kanji mode will not be used if the AllowKanjiMode property is set to false) encoding modes. The combination of encoding modes may not be the optimal one, in order to optimize encoding speed.
epSingleMode: The encoding mode will be selected automatically and applied to entire symbol, based on the barcode text, in other words, the barcode text to be encoded will be analysed, and an appropriates lowest level (highest encoding density) encoding mode will be selected, in order to minimize the symbol size, and the encoding mode will not be switched in the sybmol. Note, the Kanji mode will not be used if the AllowKanjiMode property is set to false.
The Extended Channel Interpretation (ECI) protocol allows the output data stream to have interpretations different from that of the default character set. Four broad types of interpretations are supported in QR Code:
The ECI protocol provides a consistent method to specify particular interpretations on byte values before printing and after decoding. The ECI is identified by an integer (up to 6 digits) which is encoded in the QR Code symbol by the ECI indicator block. The escape sequence "\e[<ECI_Number>]" is used to place the ECI indicator block to the barcode text:
ECI indicator blocks may be placed anywhere in the barcode text in a single or structured append set of QR Code symbols. For example:
ABC\e[123]DEFabc\e[000003]def
The default interpretation for QR Code is ECI 000003 representing the ISO/IEC 8859-1 character set.
The AllowEscape property should be set to true in order to place the ECI indicator blocks. Any ECI invoked shall apply until the end of the barcode text, or until another ECI indicator block is encountered. Thus the interpretation of the ECI may straddle two or more symbols.
In order to handle larger messages than are practical in a single symbol, a data message can be distributed across several QR Code symbols. Up to 16 QR Code symbols may be appended in a structured format to convey more data. If a symbol is part of a structured append this shall be indicated by a structured append block in barcode text. The escape sequence "\s[<Index>, <Amount>, <Parity>]" is used to place the structured append block to the barcode text:
The AllowEscape property should be set to true in order to place the structured append block. The structured append block may only be placed once in the barcode text. Also, it shall be placed at beginning of the barcode text. The OnInvalidChar or OnInvalidDataChar (only for Delphi/C++ Builder 2009 or later) event will occur if the structured append block be placed more than once, or it isn't placed at beginning of the barcode text. The following is the examples of structured append:
\s[2, 5, 125]ABCDEFGabcdefg1234567890
(*): The Data property, OnInvalidDataLength and OnInvalidDataChar events are available only for the Delphi/C++ Builder 2009 or later.