Overview
tc-lib-barcode is a pure-PHP barcode generation library for industrial, retail, logistics, and document automation workflows.
It provides deterministic, specification-driven encoding so you can generate barcode data once and render it as vectors or raster outputs depending on the target (web preview, labels, PDF pipelines). The library supports broad symbology coverage across linear, 2D, and postal barcode families.
Repository and API Docs
Installation
composer require tecnickcom/tc-lib-barcode
Where It Fits
Integrate this package when encoded symbols must be generated server-side for labels, tickets, or manifests.
Supported Formats
Linear
| Format | Description |
|---|---|
| C39 | CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9 |
| C39+ | CODE 39 with checksum |
| C39E | CODE 39 EXTENDED |
| C39E+ | CODE 39 EXTENDED + CHECKSUM |
| C93 | CODE 93 - USS-93 |
| S25 | Standard 2 of 5 |
| S25+ | Standard 2 of 5 + CHECKSUM |
| I25 | Interleaved 2 of 5 |
| I25+ | Interleaved 2 of 5 + CHECKSUM |
| C128 | CODE 128 |
| C128A | CODE 128 A |
| C128B | CODE 128 B |
| C128C | CODE 128 C |
| EAN2 | 2-Digits UPC-Based Extension |
| EAN5 | 5-Digits UPC-Based Extension |
| EAN8 | EAN 8 |
| EAN13 | EAN 13 |
| UPCA | UPC-A |
| UPCE | UPC-E |
| MSI | MSI (Variation of Plessey code) |
| MSI+ | MSI + CHECKSUM (modulo 11) |
| CODABAR | CODABAR |
| CODE11 | CODE 11 |
| PHARMA | PHARMACODE |
| PHARMA2T | PHARMACODE TWO-TRACKS |
2D
| Format | Description |
|---|---|
| AZTEC | AZTEC Code (ISO/IEC 24778:2008) |
| DATAMATRIX | DATAMATRIX (ISO/IEC 16022) |
| PDF417 | PDF417 (ISO/IEC 15438:2006) |
| QRCODE | QR-CODE |
| RAW | 2D RAW MODE comma-separated rows |
| RAW2 | 2D RAW MODE rows enclosed in square parentheses |
Postal
| Format | Description |
|---|---|
| POSTNET | POSTNET |
| PLANET | PLANET |
| RMS4CC | RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) |
| KIX | KIX (Klant index - Customer index) |
| IMB | IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 |
| IMBPRE | IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 - pre-processed |
Rendering
- HTML output for web previews.
- Image-based rendering for downstream processing.
- Configurable dimensions, padding, and color.
Output Formats
- PNG Image
- SVG Image
- HTML DIV
- Unicode String
- Binary String
Integration Notes
- Choose symbology based on scanner capability and payload constraints.
- Validate payload normalization before encoding to avoid runtime data exceptions.
- Keep scale and quiet-zone settings consistent across printer DPI profiles.
Example
<?php
require_once __DIR__ . '/vendor/autoload.php';
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
'QRCODE,H',
'https://tcpdf.org',
-4,
-4,
'black',
[-2, -2, -2, -2]
)->setBackgroundColor('white');
echo $bobj->getInlineSvgCode();