commit masivo.
[ecomupi.git] / include / tcpdf / 2dbarcodes.php
blob13e5fcbcd0a3a673df5a6dd38b48ddcd7bfdaee7
1 <?php
2 //============================================================+
3 // File name : 2dbarcodes.php
4 // Begin : 2009-04-07
5 // Last Update : 2009-04-08
6 // Version : 1.0.000
7 // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
8 // ----------------------------------------------------------------------------
9 // Copyright (C) 2008-2009 Nicola Asuni - Tecnick.com S.r.l.
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU Lesser General Public License as published by
13 // the Free Software Foundation, either version 2.1 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //
24 // See LICENSE.TXT file for more information.
25 // ----------------------------------------------------------------------------
27 // Description : PHP class to creates array representations for
28 // 2D barcodes to be used with TCPDF.
30 // Author: Nicola Asuni
32 // (c) Copyright:
33 // Nicola Asuni
34 // Tecnick.com S.r.l.
35 // Via della Pace, 11
36 // 09044 Quartucciu (CA)
37 // ITALY
38 // www.tecnick.com
39 // info@tecnick.com
40 //============================================================+
42 /**
43 * PHP class to creates array representations for 2D barcodes to be used with TCPDF.
44 * @package com.tecnick.tcpdf
45 * @abstract Functions for generating string representation of 2D barcodes.
46 * @author Nicola Asuni
47 * @copyright 2008-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
48 * @link http://www.tcpdf.org
49 * @license http://www.gnu.org/copyleft/lesser.html LGPL
50 * @version 1.0.000
53 /**
54 * PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
55 * @name TCPDFBarcode
56 * @package com.tecnick.tcpdf
57 * @version 1.0.000
58 * @author Nicola Asuni
59 * @link http://www.tcpdf.org
60 * @license http://www.gnu.org/copyleft/lesser.html LGPL
62 class TCPDF2DBarcode {
64 /**
65 * @var array representation of barcode.
66 * @access protected
68 protected $barcode_array;
70 /**
71 * This is the class constructor.
72 * Return an array representations for 2D barcodes:<ul>
73 * <li>$arrcode['code'] code to be printed on text label</li>
74 * <li>$arrcode['num_rows'] required number of rows</li>
75 * <li>$arrcode['num_cols'] required number of columns</li>
76 * <li>$arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)</li></ul>
77 * @param string $code code to print
78 * @param string $type type of barcode: <ul><li>TEST</li><li>...TO BE IMPLEMENTED</li></ul>
80 public function __construct($code, $type) {
81 $this->setBarcode($code, $type);
84 /**
85 * Return an array representations of barcode.
86 * @return array
88 public function getBarcodeArray() {
89 return $this->barcode_array;
92 /**
93 * Set the barcode.
94 * @param string $code code to print
95 * @param string $type type of barcode: <ul><li>TEST</li><li>...TO BE IMPLEMENTED</li></ul>
96 * @return array
98 public function setBarcode($code, $type) {
99 $mode = explode(',', $type);
100 switch (strtoupper($mode[0])) {
101 case 'TEST': { // TEST MODE
102 $this->barcode_array['num_rows'] = 5;
103 $this->barcode_array['num_cols'] = 15;
104 $this->barcode_array['bcode'] = array(
105 array(1,1,1,0,1,1,1,0,1,1,1,0,1,1,1),
106 array(0,1,0,0,1,0,0,0,1,0,0,0,0,1,0),
107 array(0,1,0,0,1,1,0,0,1,1,1,0,0,1,0),
108 array(0,1,0,0,1,0,0,0,0,0,1,0,0,1,0),
109 array(0,1,0,0,1,1,1,0,1,1,1,0,0,1,0)
111 break;
114 // ... Add here real 2D barcodes ...
116 default: {
117 $this->barcode_array = false;
121 } // end of class
123 //============================================================+
124 // END OF FILE
125 //============================================================+