forked from AndreasAmMueller/BarCode128
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
38 lines (27 loc) · 889 Bytes
/
example.php
File metadata and controls
38 lines (27 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once __DIR__.'/src/Barcode128.class.php';
// Text to be converted
$code = 'http://am-wd.de';
// Text printed above the barcode
$text = 'BarCode128';
// A font file located in the same directory
// http://openfontlibrary.org/en/font/hans-kendrick
$font = __DIR__."/data/HansKendrick-Regular.ttf";
// corresponding fontsize in px
$fontSize = 12;
// height of the barcode in px
$height = 130;
// create an Object of BarCode128 Class
$barcode = new AMWD\BarCode128($code, $height);
// OPTIONAL: add the font
// if not: no Text can be written (only bars)
$barcode->addFont($font, $fontSize);
// OPTIONAL: add the text above the barcode
$barcode->CustomText($text);
/*
* with $barcode->draw() the raw image will be echoed to the stdout
* with $barcode->save('barcode.jpg') the image will be saved as jpg
**/
$barcode->draw();
//$barcode->save('data/barcode.gif');
?>