Skip to content

Commit bd486cf

Browse files
committed
First version
0 parents  commit bd486cf

9 files changed

+3188
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
.DS_Store

Readme.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# PHP Barcode Generator
2+
This is an easy to use, non-bloated, framework independent, barcode generator in PHP.
3+
4+
It creates SVG, PNG, JPG and HTML images, from the most used 1D barcode standards.
5+
6+
*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.*
7+
8+
## Installation
9+
Install through [composer](https://getcomposer.org/doc/00-intro.md):
10+
11+
```
12+
composer require picqer/php-barcode-generator
13+
```
14+
15+
## Usage
16+
Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want.
17+
18+
```php
19+
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
20+
echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_128);
21+
```
22+
23+
The ->getBarcode() routine accepts the following:
24+
- $code Data for the barcode
25+
- $type Type of barcode, use the constants defined in the class
26+
- $widthFactor Width is based on the length of the data, with this factor you can make the barcode bars wider then default
27+
- $totalHeight The total height of the barcode
28+
- $color Hex code of the foreground color
29+
30+
## Image types
31+
```php
32+
$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG();
33+
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
34+
$generatorJPG = new Picqer\Barcode\BarcodeGeneratorJPG();
35+
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML();
36+
```
37+
38+
## Accepted types
39+
- TYPE_CODE_39
40+
- TYPE_CODE_39_CHECKSUM
41+
- TYPE_CODE_39E
42+
- TYPE_CODE_39E_CHECKSUM
43+
- TYPE_CODE_93
44+
- TYPE_STANDARD_2_5
45+
- TYPE_STANDARD_2_5_CHECKSUM
46+
- TYPE_INTERLEAVED_2_5
47+
- TYPE_INTERLEAVED_2_5_CHECKSUM
48+
- TYPE_CODE_128
49+
- TYPE_CODE_128_A
50+
- TYPE_CODE_128_B
51+
- TYPE_CODE_128_C
52+
- TYPE_EAN_2
53+
- TYPE_EAN_5
54+
- TYPE_EAN_8
55+
- TYPE_EAN_13
56+
- TYPE_UPC_A
57+
- TYPE_UPC_E
58+
- TYPE_MSI
59+
- TYPE_MSI_CHECKSUM
60+
- TYPE_POSTNET
61+
- TYPE_PLANET
62+
- TYPE_RMS4CC
63+
- TYPE_KIX
64+
- TYPE_IMB
65+
- TYPE_CODABAR
66+
- TYPE_CODE_11
67+
- TYPE_PHARMA_CODE
68+
- TYPE_PHARMA_CODE_TWO_TRACKS
69+
70+
## Examples
71+
Embedded PNG image in HTML:
72+
73+
```php
74+
$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
75+
echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723897', $generator::TYPE_CODE_128)) . '">';
76+
```

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "picqer/php-barcode-generator",
3+
"type": "library",
4+
"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.",
5+
"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" ],
6+
"homepage": "http://github.com/picqer/exact-php-client",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Casper Bakker",
11+
"email": "info@picqer.com"
12+
}
13+
],
14+
"require": {
15+
"php": ">=5.4.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Picqer\\Barcode\\": "src"
20+
}
21+
}
22+
}

examples.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
include('src/BarcodeGenerator.php');
4+
include('src/BarcodeGeneratorPNG.php');
5+
include('src/BarcodeGeneratorSVG.php');
6+
include('src/BarcodeGeneratorHTML.php');
7+
8+
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
9+
$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG();
10+
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML();
11+
12+
echo $generatorHTML->getBarcode('081231723897', $generatorPNG::TYPE_CODE_128);
13+
echo $generatorSVG->getBarcode('081231723897', $generatorPNG::TYPE_EAN_13);
14+
echo '<img src="data:image/png;base64,' . base64_encode($generatorPNG->getBarcode('081231723897', $generatorPNG::TYPE_CODE_128)) . '">';

0 commit comments

Comments
 (0)