Home » Images » Image_Barcode » Manual
Introduction
Image_Barcode lets you create barcode representations of strings. The package supports multiple drivers, letting you create barcodes of the following type:
- Code 39
- Code 128
- EAN 13
- INT 25
- PostNet
- UPCA
Using Image_Barcode
Creating a barcode is as simple as calling the classes
static draw() method after including
Image/Barcode.php.
The method has four parameters: The first is the string that shall be
converted into barcode representation. The second parameter determines
which driver/type should be used; it is one of:
Code39, code128,
ean13, int25,
postnet or upca.
The case difference between
Code39andcode128has no reason and makes no sense, but is kept because of backward compatibility.
The third parameter of draw() determines
the type of the image that is generated; one of
jpg, png and
gif.
By default, the image generated by the barcode driver is directly
output to the browser. If you do not want this, pass
false as fourth parameter and
draw() will return the GD image resource
object; allowing you to do further things with it.
Simple example
<?php
require_once 'Image/Barcode.php';
Image_Barcode::draw('1234', 'int25', 'png');
?>
As with all PEAR packages, installing the package also installs
some more examples in the docs/Image_Barcode
directory of your PEAR installation.