PHP Barcode Generator

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 largely from the TCPDF barcode generator by Nicola Asuni. This code is therefor licensed under LGPLv3. It is still a bit of a mess, bit I will clean it in the future. I do not expect the interface of this class will change during the clean ups.
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.
$generator = new PicqerBarcodeBarcodeGeneratorHTML(); echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_128);
The ->getBarcode() routine accepts the following:
$code Data for 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 $totalHeight The total height of the barcode $color Hex code of the foreground colorImage types
$generatorSVG = new PicqerBarcodeBarcodeGeneratorSVG(); $generatorPNG = new PicqerBarcodeBarcodeGeneratorPNG(); $generatorJPG = new PicqerBarcodeBarcodeGeneratorJPG(); $generatorHTML = new PicqerBarcodeBarcodeGeneratorHTML();
Accepted types
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_TRACKSExamples
Embedded PNG image in HTML:
$generator = new PicqerBarcodeBarcodeGeneratorPNG(); echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723897', $generator::TYPE_CODE_128)) . '">';
优化
调整了PNG和JPG图片生成代码,在图片下方会带上条码文本
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。