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

FormatDescription
C39CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9
C39+CODE 39 with checksum
C39ECODE 39 EXTENDED
C39E+CODE 39 EXTENDED + CHECKSUM
C93CODE 93 - USS-93
S25Standard 2 of 5
S25+Standard 2 of 5 + CHECKSUM
I25Interleaved 2 of 5
I25+Interleaved 2 of 5 + CHECKSUM
C128CODE 128
C128ACODE 128 A
C128BCODE 128 B
C128CCODE 128 C
EAN22-Digits UPC-Based Extension
EAN55-Digits UPC-Based Extension
EAN8EAN 8
EAN13EAN 13
UPCAUPC-A
UPCEUPC-E
MSIMSI (Variation of Plessey code)
MSI+MSI + CHECKSUM (modulo 11)
CODABARCODABAR
CODE11CODE 11
PHARMAPHARMACODE
PHARMA2TPHARMACODE TWO-TRACKS

2D

FormatDescription
AZTECAZTEC Code (ISO/IEC 24778:2008)
DATAMATRIXDATAMATRIX (ISO/IEC 16022)
PDF417PDF417 (ISO/IEC 15438:2006)
QRCODEQR-CODE
RAW2D RAW MODE comma-separated rows
RAW22D RAW MODE rows enclosed in square parentheses

Postal

FormatDescription
POSTNETPOSTNET
PLANETPLANET
RMS4CCRMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
KIXKIX (Klant index - Customer index)
IMBIMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
IMBPREIMB - 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();