You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -7,8 +7,6 @@ This is an easy to use, non-bloated, framework independent, barcode generator in
7
7
8
8
It creates SVG, PNG, JPG and HTML images, from the most used 1D barcode standards.
9
9
10
-
*The codebase is based on the [TCPDF barcode generator](https://github.com/tecnickcom/TCPDF) by Nicola Asuni. This code is therefor licensed under LGPLv3.*
11
-
12
10
## No support for...
13
11
- No support for any **2D** barcodes, like QR codes.
14
12
- We only generate the 'bars' part of a barcode, without text below the barcode. If you want text of the code below the barcode, you could add it later to the output of this package.
If you want to generate PNG or JPG images, you need the GD library or Imagick installed on your system as well.
24
22
25
23
## Usage
26
-
Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want.
24
+
You want a barcode for a specific "type" (for example Code 128 or UPC) in a specific image format (for example PNG or SVG).
25
+
26
+
> The "type" is a standard that defines which characters you can encode and which bars represent which character. The most used types are [code 128](https://en.wikipedia.org/wiki/Code_128) and [EAN/UPC](https://en.wikipedia.org/wiki/International_Article_Number). Not all characters can be encoded into each barcode type, and not all barcode scanners can read all types.
27
+
28
+
First, encode the string you want the barcode of into a `Barcode` object with one of the barcode types.
29
+
Then, use one of the renderers to render the image of the bars in the `Barcode` object.
27
30
28
31
```php
29
32
<?php
30
33
require 'vendor/autoload.php';
31
34
32
-
// This will output the barcode as HTML output to display in the browser
33
-
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG(); // Vector based SVG
63
-
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG(); // Pixel based PNG
64
-
$generatorJPG = new Picqer\Barcode\BarcodeGeneratorJPG(); // Pixel based JPG
65
-
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML(); // Pixel based HTML
66
-
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorDynamicHTML(); // Vector based HTML
63
+
$renderer = new Picqer\Barcode\Renderers\SvgRenderer(); // Vector based SVG
64
+
$renderer = new Picqer\Barcode\Renderers\PngRenderer(); // Pixel based PNG
65
+
$renderer = new Picqer\Barcode\Renderers\JpgRenderer(); // Pixel based JPG
66
+
$renderer = new Picqer\Barcode\Renderers\HtmlRenderer(); // Pixel based HTML
67
+
$renderer = new Picqer\Barcode\Renderers\DynamicHtmlRenderer(); // Vector based HTML (full 'page' width and height)
67
68
```
68
69
69
70
## Accepted barcode types
70
-
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.
71
+
These barcode types are supported. All types support different character sets and some have mandatory lengths. Please see wikipedia for supported chars and lengths per type.
72
+
73
+
You can find all supported types in the [src/Types](src/Types) folder.
71
74
72
75
Most used types are TYPE_CODE_128 and TYPE_CODE_39. Because of the best scanner support, variable length and most chars supported.
73
76
@@ -107,23 +110,98 @@ Most used types are TYPE_CODE_128 and TYPE_CODE_39. Because of the best scanner
107
110
[See example images for all supported barcode types](examples.md)
108
111
109
112
## A note about PNG and JPG images
110
-
If you want to use PNG or JPG images, you need to install [Imagick](https://www.php.net/manual/en/intro.imagick.php) or the [GD library](https://www.php.net/manual/en/intro.image.php). 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.
113
+
If you want to use PNG or JPG images, you need to install [Imagick](https://www.php.net/manual/en/intro.imagick.php) or the [GD library](https://www.php.net/manual/en/intro.image.php). 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 `$renderer->useGd()` or `$renderer->useImagick()` to force your preference.
111
114
112
115
## Examples
113
116
114
117
### Embedded PNG image in HTML
115
118
```php
119
+
$barcode = (new Picqer\Barcode\Types\TypeCode128())->getBarcode('081231723897');
120
+
$renderer = new Picqer\Barcode\Renderers\PngRenderer();
file_put_contents('barcode.svg', (new Picqer\Barcode\Renderers\SvgRenderer())->render((new Picqer\Barcode\Types\TypeKix())->getBarcode('6825ME601')));
135
+
```
136
+
137
+
## Upgrading to v3
138
+
There is no need to change anything when upgrading from v2 to v3. Above you find the new preferred way of using this library since v3. But the old style still works.
139
+
140
+
---
141
+
142
+
## Previous style generators
143
+
In version 3 the barcode type encoders and image renderers are completely separate. This makes building your own renderer way easier. The old way was using "generators". Below are the old examples of these generators, which still works in v3 as well.
144
+
145
+
### Usage
146
+
Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want.
147
+
148
+
```php
149
+
<?php
150
+
require 'vendor/autoload.php';
151
+
152
+
// This will output the barcode as HTML output to display in the browser
153
+
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
file_put_contents('barcode.svg', (new Picqer\Barcode\BarcodeGeneratorSVG())->getBarcode('6825ME601', Picqer\Barcode\BarcodeGeneratorSVG::TYPE_KIX));
129
204
```
205
+
206
+
---
207
+
*The codebase is based on the [TCPDF barcode generator](https://github.com/tecnickcom/TCPDF) by Nicola Asuni. This code is therefor licensed under LGPLv3.*
0 commit comments