ndtan/ndt-multi-code

NDT Multi-Code: unified PHP library to generate QR, DataMatrix, UPC/EAN, Code 39/93/128, ITF, PDF417 (Aztec planned) with simple & advanced options (SVG/PNG/JPG/TIFF/PDF/GIF/WebP).

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ndtan/ndt-multi-code

dev-main 2025-10-13 08:38 UTC

This package is auto-updated.

Last update: 2025-10-13 08:43:45 UTC


README

Author: Tony Nguyen • Email: admin@ndtan.net • Website: https://nguyenduytan.com
Namespace: ndtan • License: MIT

A unified PHP library to generate QR, Data Matrix, UPC-A / UPC-E, EAN-8 / EAN-13, Code 39 / Code 93 / Code 128, ITF, PDF417 (Aztec planned) with simple & advanced options. Output formats: SVG (default), PNG, JPG, TIFF, PDF, GIF, WebP.

Install

composer require ndtan/ndt-multi-code

Requires PHP >= 8.1. For raster/PDF outputs, consider installing ext-gd, ext-imagick or dompdf/dompdf.

Quick Start

Simple

use ndtan\Core\Generator;

$gen = new Generator();                 // SVG default
$res = $gen->generate('qr', 'HELLO NDT');
file_put_contents('qr.svg', $res->getBytes());

Advanced

use ndtan\Core\Generator;

$gen = new Generator();
$res = $gen->generate('code128', '1234567890', [
  'format' => 'png',
  'moduleSize' => 3,
  'margin' => 10,
  'foreground' => '#111',
  'background' => '#fff0',
  'humanReadable' => [
    'enabled' => true,
    'text' => null,
    'fontSize' => 12,
    'position' => 'bottom'
  ],
  // Symbology-specific:
  'subset' => 'C',   // Code128 A|B|C|auto
  'fnc1' => false
]);
file_put_contents('code128.png', $res->getBytes());

Supported Types & Constraints (summary)

  • qr — Options: version(1-40|auto), ecc(L|M|Q|H), mask(0-7|auto), eci, micro(false); Quiet zone ≥ 4 modules.
  • datamatrix — Options: size(auto|fixed), encoding(auto|ASCII|C40|Text|X12|EDIFACT|Base256); Quiet zone ≥ 1 module.
  • pdf417 — Options: columns(1-30), rows(3-90), securityLevel(0-8), compact, aspectRatio.
  • code128 — Options: subset(A|B|C|auto), fnc1.
  • code39 — Options: fullAscii, checksumMod43, narrowToWideRatio(2.0-3.0); Alphabet restrictions.
  • code93 — Options: fullAscii; auto C & K checksums.
  • itf — Options: bearerBars(none|frame|top-bottom), checksum, narrowToWideRatio; Numeric, even length.
  • ean13/ean8 — Numeric only; EAN-13 length 12 data; EAN-8 length 7 data (checksums auto).
  • upca/upce — UPC-A length 11 data; UPC-E 6 data (compressible subset only).
  • aztec — Planned; currently returns E_UNSUPPORTED_TYPE.

CLI

./bin/ndt-multi-code --type qr --data "Xin chao" --format svg --out out/qr.svg --ecc Q --margin 8

HTTP demo

php -S localhost:8080 -t src/Http
# GET http://localhost:8080/?type=ean13&data=590123412345&format=png

Tests

composer install
vendor/bin/phpunit

Notes

  • Raster/PDF require appropriate extensions (GD/Imagick/Dompdf). If missing, you'll get E_RENDERER_BACKEND_MISSING or a graceful fallback to SVG.
  • Aztec is planned; for now the generator throws E_UNSUPPORTED_TYPE.