-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bd486cf
Showing
9 changed files
with
3,188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# 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. 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](https://getcomposer.org/doc/00-intro.md): | ||
|
||
``` | ||
composer require picqer/php-barcode-generator | ||
``` | ||
|
||
## Usage | ||
Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want. | ||
|
||
```php | ||
$generator = new Picqer\Barcode\BarcodeGeneratorHTML(); | ||
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 then default | ||
- $totalHeight The total height of the barcode | ||
- $color Hex code of the foreground color | ||
|
||
## Image types | ||
```php | ||
$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG(); | ||
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG(); | ||
$generatorJPG = new Picqer\Barcode\BarcodeGeneratorJPG(); | ||
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML(); | ||
``` | ||
|
||
## 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_TRACKS | ||
|
||
## Examples | ||
Embedded PNG image in HTML: | ||
|
||
```php | ||
$generator = new Picqer\Barcode\BarcodeGeneratorPNG(); | ||
echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723897', $generator::TYPE_CODE_128)) . '">'; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "picqer/php-barcode-generator", | ||
"type": "library", | ||
"description": "An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.", | ||
"keywords": [ "php", "barcode", "barcode generator", "EAN", "EAN13", "UPC", "Code39", "Code128", "Code93", "Standard 2 of 5", "MSI", "POSTNET", "KIX", "KIXCODE", "CODABAR", "PHARMA", "Code11", "SVG", "PNG", "HTML", "JPG", "JPEG" ], | ||
"homepage": "http://github.com/picqer/exact-php-client", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Casper Bakker", | ||
"email": "info@picqer.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Picqer\\Barcode\\": "src" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
include('src/BarcodeGenerator.php'); | ||
include('src/BarcodeGeneratorPNG.php'); | ||
include('src/BarcodeGeneratorSVG.php'); | ||
include('src/BarcodeGeneratorHTML.php'); | ||
|
||
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG(); | ||
$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG(); | ||
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML(); | ||
|
||
echo $generatorHTML->getBarcode('081231723897', $generatorPNG::TYPE_CODE_128); | ||
echo $generatorSVG->getBarcode('081231723897', $generatorPNG::TYPE_EAN_13); | ||
echo '<img src="data:image/png;base64,' . base64_encode($generatorPNG->getBarcode('081231723897', $generatorPNG::TYPE_CODE_128)) . '">'; |
Oops, something went wrong.