All Projects → picqer → Php Barcode Generator

picqer / Php Barcode Generator

Licence: lgpl-3.0
Barcode generator in PHP that is easy to use, non-bloated and framework independent.

Labels

Projects that are alternatives of or similar to Php Barcode Generator

Ngx Scanner
Angular (2+) QR code, Barcode, DataMatrix, scanner component using ZXing.
Stars: ✭ 420 (-60.26%)
Mutual labels:  barcode
Brocade.io
Open GTIN / barcode & product database
Stars: ✭ 24 (-97.73%)
Mutual labels:  barcode
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (-7.1%)
Mutual labels:  barcode
Code Scanner
Code scanner library for Android, based on ZXing
Stars: ✭ 543 (-48.63%)
Mutual labels:  barcode
Td Angular Barcode
Barcode Generator for Angular 1 (Supports 90+ barcode types: qr, aztec, code128, ean, isbn, interleaved2of5, ...)
Stars: ✭ 22 (-97.92%)
Mutual labels:  barcode
Qr
IEC18004 (QR) 2D barcode generation library and command line
Stars: ✭ 20 (-98.11%)
Mutual labels:  barcode
Barcodelib
C# Barcode Image Generation Library
Stars: ✭ 407 (-61.49%)
Mutual labels:  barcode
Fiscalberry
[JSON ↔ HW] Connect things using JSON API with the fiscalberry websocket server interact easily with any kind of Hardware. Another IoT solution...
Stars: ✭ 44 (-95.84%)
Mutual labels:  barcode
Zxingview
👍 Lowest cost integration and most convenient customization zxing on android
Stars: ✭ 23 (-97.82%)
Mutual labels:  barcode
Barcode
a barcode creation lib for golang
Stars: ✭ 953 (-9.84%)
Mutual labels:  barcode
Uhttbarcodereference
Universe-HTT barcode reference
Stars: ✭ 634 (-40.02%)
Mutual labels:  barcode
Barcode
Laravel 5 Barcode Generator
Stars: ✭ 826 (-21.85%)
Mutual labels:  barcode
Ngx Barcode Scanner
An angular barcode reader
Stars: ✭ 29 (-97.26%)
Mutual labels:  barcode
Passandroid
Android App to view passes
Stars: ✭ 543 (-48.63%)
Mutual labels:  barcode
Library
Multi-format 1D/2D barcode image processing library, usable in JavaScript ecosystem.
Stars: ✭ 1,006 (-4.82%)
Mutual labels:  barcode
Efqrcode
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.
Stars: ✭ 4,121 (+289.88%)
Mutual labels:  barcode
Czxing
C++ port of ZXing and ZBar for Android.
Stars: ✭ 854 (-19.21%)
Mutual labels:  barcode
Barcoded
A barcode generation web service.
Stars: ✭ 48 (-95.46%)
Mutual labels:  barcode
Mybox
Easy tools of document, image, file, network, location, color, and media.
Stars: ✭ 45 (-95.74%)
Mutual labels:  barcode
Mlkit
A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Stars: ✭ 949 (-10.22%)
Mutual labels:  barcode

PHP Barcode Generator

Build Status Github Actions Total Downloads

This is an easy to use, non-bloated, framework independent, barcode generator in PHP.

It creates SVG, PNG, JPG and HTML images, from the most used 1D barcode standards.

The codebase is based on the TCPDF barcode generator by Nicola Asuni. This code is therefor licensed under LGPLv3.

No support for...

We do not support any 2D barcodes, like QR codes. We also only generate the 'bars' part of a barcode. If you want text of the code below the barcode, you could add it later to the output of this package.

Installation

Install through composer:

composer require picqer/php-barcode-generator

If you want to generate PNG or JPG images, you need the GD library or Imagick installed on your system as well.

Usage

Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want.

<?php
require 'vendor/autoload.php';

// This will output the barcode as HTML output to display in the browser
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_128);

The getBarcode() method accepts the following parameters:

  • $barcode String needed to encode in the barcode
  • $type Type of barcode, use the constants defined in the class
  • $widthFactor Width is based on the length of the data, with this factor you can make the barcode bars wider than default
  • $height The total height of the barcode in pixels
  • $foregroundColor Hex code as string, or array of RGB, of the colors of the bars (the foreground color)

Example of usage of all parameters:

<?php

require 'vendor/autoload.php';

$redColor = [255, 0, 0];

$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
file_put_contents('barcode.png', $generator->getBarcode('081231723897', $generator::TYPE_CODE_128, 3, 50, $redColor));

Image types

$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG();
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
$generatorJPG = new Picqer\Barcode\BarcodeGeneratorJPG();
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML();

Accepted barcode types

These barcode types are supported. All types support different character sets or have mandatory lengths. Please see wikipedia for supported chars and lengths per type.

Most used types are TYPE_CODE_128 and TYPE_CODE_39. Because of the best scanner support, variable length and most chars supported.

  • TYPE_CODE_39
  • TYPE_CODE_39_CHECKSUM
  • TYPE_CODE_39E
  • TYPE_CODE_39E_CHECKSUM
  • TYPE_CODE_93
  • TYPE_STANDARD_2_5
  • TYPE_STANDARD_2_5_CHECKSUM
  • TYPE_INTERLEAVED_2_5
  • TYPE_INTERLEAVED_2_5_CHECKSUM
  • TYPE_CODE_128
  • TYPE_CODE_128_A
  • TYPE_CODE_128_B
  • TYPE_CODE_128_C
  • TYPE_EAN_2
  • TYPE_EAN_5
  • TYPE_EAN_8
  • TYPE_EAN_13
  • TYPE_UPC_A
  • TYPE_UPC_E
  • TYPE_MSI
  • TYPE_MSI_CHECKSUM
  • TYPE_POSTNET
  • TYPE_PLANET
  • TYPE_RMS4CC
  • TYPE_KIX
  • TYPE_IMB
  • TYPE_CODABAR
  • TYPE_CODE_11
  • TYPE_PHARMA_CODE
  • TYPE_PHARMA_CODE_TWO_TRACKS

See example images for all supported barcode types

A note about PNG and JPG images

If you want to use PNG or JPG images, you need to install Imagick or the GD library. This package will use Imagick if that is installed, or fall back to GD. If you have both installed but you want a specific method, you can use $generator->useGd() or $generator->useImagick() to force your preference.

Examples

Embedded PNG image in HTML

$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723897', $generator::TYPE_CODE_128)) . '">';

Save JPG barcode to disk

$generator = new Picqer\Barcode\BarcodeGeneratorJPG();
file_put_contents('barcode.jpg', $generator->getBarcode('081231723897', $generator::TYPE_CODABAR));

Oneliner SVG output to disk

file_put_contents('barcode.svg', (new Picqer\Barcode\BarcodeGeneratorSVG())->getBarcode('6825ME601', Picqer\Barcode\BarcodeGeneratorSVG::TYPE_KIX));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].