| 1 |
jonen |
1.1 |
PHP-Barcode 0.3pl1 |
| 2 |
|
|
|
| 3 |
|
|
PHP-Barcode generates |
| 4 |
|
|
- Barcode-Images using libgd (png, jpg,gif), |
| 5 |
|
|
- HTML-Images (using 1x1 pixel and html-table) |
| 6 |
|
|
- silly Text-Barcodes |
| 7 |
|
|
|
| 8 |
|
|
PHP-Barcode encodes using |
| 9 |
|
|
- a built-in EAN-13/ISBN Encoder |
| 10 |
|
|
- genbarcode (by Folke Ashberg), a command line |
| 11 |
|
|
barcode-encoder which uses GNU-Barcode |
| 12 |
|
|
genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c), |
| 13 |
|
|
I25, 128RAW, CBR, MSI, PLS |
| 14 |
|
|
genbarcode is available at www.ashberg.de/bar |
| 15 |
|
|
|
| 16 |
|
|
(C) 2001,2002,2003,2004 by Folke Ashberg <folke@ashberg.de> |
| 17 |
|
|
|
| 18 |
|
|
The newest version can be found at http://www.ashberg.de/bar |
| 19 |
|
|
|
| 20 |
|
|
|
| 21 |
|
|
INSTALLATION: |
| 22 |
|
|
|
| 23 |
|
|
WHAT YOU NEED TO BE ABLE TO USE PHP-BARCODE |
| 24 |
|
|
You need php>4 on your system. |
| 25 |
|
|
You need the gd2-extension to be able to render images. |
| 26 |
|
|
You need a TrueTypeFont if you want to see the CODE below the bars. |
| 27 |
|
|
You need genbarcode (from www.ashberg.de/bar) in you want to use |
| 28 |
|
|
another encoding than EAN-12/EAN-12/ISBN |
| 29 |
|
|
|
| 30 |
|
|
Copy the following files into your html/php-directory |
| 31 |
|
|
- php-barcode.php - main library |
| 32 |
|
|
- encode_bars.php - built-in encoders |
| 33 |
|
|
optional: |
| 34 |
|
|
- barcode.php - Sample-File |
| 35 |
|
|
- white.png - for HTML-Images |
| 36 |
|
|
- black.png - for HTML-Images |
| 37 |
|
|
|
| 38 |
|
|
FONT-Installation |
| 39 |
|
|
UNIX: |
| 40 |
|
|
A TrueTypeFont isn't included in this distribution! |
| 41 |
|
|
Copy one into the html/php-directory and change in php-barcode.php |
| 42 |
|
|
$font_loc (change the arialbd.tff to your font name). |
| 43 |
|
|
arialbd.ttf from Windows looks great. |
| 44 |
|
|
|
| 45 |
|
|
WINDOWS: |
| 46 |
|
|
If you use Windows the font should be located automatically. |
| 47 |
|
|
|
| 48 |
|
|
OPTIONAL - genbarcode: |
| 49 |
|
|
If you want to generate not only EAN-12/EAN-13/ISBN-Codes you have to install |
| 50 |
|
|
genbarcode, a small unix-commandline tool which uses GNU-Barcode. |
| 51 |
|
|
genbarcode is available http://www.ashberg.de/bar , read genbarcodes |
| 52 |
|
|
README for installation. |
| 53 |
|
|
If you have installed genbarcode not to /usr/bin set the $genbarcode_loc |
| 54 |
|
|
in php-barcode.php . |
| 55 |
|
|
|
| 56 |
|
|
TESTING |
| 57 |
|
|
If everything works fine you should see an image if you call |
| 58 |
|
|
http://localhost/path/barcode.php |
| 59 |
|
|
|
| 60 |
|
|
Or call http://localhost/path/barcode.php?code=<CODE>&encoding=<ENCODING>&mode=<png|jpg|gif|html|text>&size=<1,2,3,...> |
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
|
| 64 |
|
|
If you need more then the sample barcode.php can do, you need to build your own. |
| 65 |
|
|
|
| 66 |
|
|
FUNCTIONS - API-Reference |
| 67 |
|
|
|
| 68 |
|
|
-------------------------------------------------------------------------- |
| 69 |
|
|
function barcode_encode(code, encoding) |
| 70 |
|
|
encodes $code with $encoding using genbarcode OR built-in encoder |
| 71 |
|
|
if you don't have genbarcode only EAN-13/ISBN is possible |
| 72 |
|
|
|
| 73 |
|
|
You can use the following encodings (when you have genbarcode): |
| 74 |
|
|
ANY choose best-fit (default) |
| 75 |
|
|
EAN 8 or 13 EAN-Code |
| 76 |
|
|
UPC 12-digit EAN |
| 77 |
|
|
ISBN isbn numbers (still EAN-13) |
| 78 |
|
|
39 code 39 |
| 79 |
|
|
128 code 128 (a,b,c: autoselection) |
| 80 |
|
|
128C code 128 (compact form for digits) |
| 81 |
|
|
128B code 128, full printable ascii |
| 82 |
|
|
I25 interleaved 2 of 5 (only digits) |
| 83 |
|
|
128RAW Raw code 128 (by Leonid A. Broukhis) |
| 84 |
|
|
CBR Codabar (by Leonid A. Broukhis) |
| 85 |
|
|
MSI MSI (by Leonid A. Broukhis) |
| 86 |
|
|
PLS Plessey (by Leonid A. Broukhis) |
| 87 |
|
|
|
| 88 |
|
|
return: |
| 89 |
|
|
array[encoding] : the encoding which has been used |
| 90 |
|
|
array[bars] : the bars |
| 91 |
|
|
array[text] : text-positioning info |
| 92 |
|
|
|
| 93 |
|
|
-------------------------------------------------------------------------- |
| 94 |
|
|
function barcode_outimage(text, bars [, scale [, mode [, total_y [, space ]]]] ) |
| 95 |
|
|
|
| 96 |
|
|
Outputs an image using libgd |
| 97 |
|
|
|
| 98 |
|
|
text : the text-line (<position>:<font-size>:<character> ...) |
| 99 |
|
|
bars : where to place the bars (<space-width><bar-width><space-width><bar-width>...) |
| 100 |
|
|
scale : scale factor ( 1 < scale < unlimited (scale 50 will produce |
| 101 |
|
|
5400x300 pixels when |
| 102 |
|
|
using EAN-13!!!)) |
| 103 |
|
|
mode : png,gif,jpg, depending on libgd ! (default='png') |
| 104 |
|
|
total_y: the total height of the image ( default: scale * 60 ) |
| 105 |
|
|
space : space |
| 106 |
|
|
default: |
| 107 |
|
|
$space[top] = 2 * $scale; |
| 108 |
|
|
$space[bottom]= 2 * $scale; |
| 109 |
|
|
$space[left] = 2 * $scale; |
| 110 |
|
|
$space[right] = 2 * $scale; |
| 111 |
|
|
|
| 112 |
|
|
-------------------------------------------------------------------------- |
| 113 |
|
|
function barcode_outhtml(text, bars [, scale [, total_y [, space ]]] ) |
| 114 |
|
|
|
| 115 |
|
|
returns(!) HTML-Code for barcode-image using html-code (using a table and with black.png and white.png) |
| 116 |
|
|
|
| 117 |
|
|
text : the text-line (<position>:<font-size>:<character> ...) |
| 118 |
|
|
bars : where to place the bars (<space-width><bar-width><space-width><bar-width>...) |
| 119 |
|
|
scale : scale factor ( 1 < scale < unlimited (scale 50 will produce |
| 120 |
|
|
5400x300 pixels when |
| 121 |
|
|
using EAN-13!!!)) |
| 122 |
|
|
total_y: the total height of the image ( default: scale * 60 ) |
| 123 |
|
|
space : space |
| 124 |
|
|
default: |
| 125 |
|
|
$space[top] = 2 * $scale; |
| 126 |
|
|
$space[bottom]= 2 * $scale; |
| 127 |
|
|
$space[left] = 2 * $scale; |
| 128 |
|
|
$space[right] = 2 * $scale; |
| 129 |
|
|
|
| 130 |
|
|
-------------------------------------------------------------------------- |
| 131 |
|
|
function barcode_outtext(code, bars) |
| 132 |
|
|
|
| 133 |
|
|
Returns (!) a barcode as plain-text |
| 134 |
|
|
ATTENTION: this is very silly! |
| 135 |
|
|
|
| 136 |
|
|
text : the text-line (<position>:<font-size>:<character> ...) |
| 137 |
|
|
bars : where to place the bars (<space-width><bar-width><space-width><bar-width>...) |
| 138 |
|
|
|
| 139 |
|
|
-------------------------------------------------------------------------- |
| 140 |
|
|
For more function see php-barcode.php |
| 141 |
|
|
Also see barcode.php or just use them :) |
| 142 |
|
|
|
| 143 |
|
|
|
| 144 |
|
|
|
| 145 |
|
|
|
| 146 |
|
|
|
| 147 |
|
|
|
| 148 |
|
|
This program is free software; you can redistribute it and/or modify |
| 149 |
|
|
it under the terms of the GNU General Public License as published by |
| 150 |
|
|
the Free Software Foundation; either version 2 of the License, or |
| 151 |
|
|
(at your option) any later version. |
| 152 |
|
|
|
| 153 |
|
|
This program is distributed in the hope that it will be useful, |
| 154 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 155 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 156 |
|
|
GNU General Public License for more details. |
| 157 |
|
|
|
| 158 |
|
|
You should have received a copy of the GNU General Public License |
| 159 |
|
|
along with this program; if not, write to the Free Software |
| 160 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 161 |
|
|
|
| 162 |
|
|
|