Denso Wave designed the QR Code in 1994 to track parts on a production line, and its three finder patterns are why a phone can read one at any angle. Forty versions, from 21 modules square to 177, and four error correction levels that trade capacity for damage tolerance: L recovers about 7 per cent of the symbol, H about 30.
Leave the version at 0 and the library picks the smallest symbol the data fits. QR Code is a registered trademark of DENSO WAVE INCORPORATED.
Type Token
| Item | Value |
|---|---|
| Type token | QRCODE |
| Enum case | BarcodeType::QRCODE |
| Family | 2D |
| Standard | ISO/IEC 18004 |
| Class | \Com\Tecnick\Barcode\Type\Square\QrCode |
Input
| Item | Value |
|---|---|
| Character set | any byte sequence; the encoder switches between numeric, alphanumeric, byte and kanji modes |
| Length | up to 7089 digits, 4296 alphanumeric characters or 2953 bytes, depending on version and error correction |
| Check | Reed-Solomon error correction, computed by the library |
| Extra parameters | 7 (see below) |
Extra Parameters
Appended to the type token after commas, as in QRCODE,H.
| Position | Meaning | Values | Default |
|---|---|---|---|
| 1 | error correction level | L, M, Q, H | L |
| 2 | encoding mode | NL, NM, AN, 8B, KJ, ST | 8B |
| 3 | version | 0 for automatic, or 1 to 40 | 0 |
| 4 | case sensitivity | 1 or 0 | 1 |
| 5 | random mask count | number of masks to try | unset |
| 6 | best mask search | 1 or 0 | 1 |
| 7 | default mask | 0 to 7 | 2 |
Examples
Digits at the default error correction level
<?php
require_once __DIR__ . '/vendor/autoload.php';
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
type: 'QRCODE',
code: '0123456789',
width: -4,
height: -4,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
echo $bobj->getInlineSvgCode();
A URL at the highest error correction level
$bobj = $barcode->getBarcodeObj(
type: 'QRCODE,H',
code: 'https://tcpdf.org',
width: -4,
height: -4,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
A fixed version 4 symbol, larger than the data needs
$bobj = $barcode->getBarcodeObj(
type: 'QRCODE,M,NL,4',
code: 'tc-lib-barcode',
width: -4,
height: -4,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
Errors
These payloads raise \Com\Tecnick\Barcode\Exception:
| Payload | Message |
|---|---|
| `` | Empty input |
See Also
- tc-lib-barcode : the library overview.
- Rendering Options : size, colour, padding.
- Output Formats : every renderer.
- Micro QR Code : the small-symbol variant.
- HIBC in QR Code : a QR Code carrying an HIBC data structure.
- Datamatrix : the other widely used matrix format.
- API reference : the generated class documentation.