| @@ -4,11 +4,11 @@ | ||
| 4 | 4 | // Version : 1.0.015 |
| 5 | 5 | // Begin : 2009-04-07 |
| 6 | 6 | // Last Update : 2014-05-20 |
| 7 | 7 | // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected] |
| 8 | -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) | |
| 8 | +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) | |
| 9 | 9 | // ------------------------------------------------------------------- |
| 10 | -// Copyright (C) 2009-2014 Nicola Asuni - Tecnick.com LTD | |
| 10 | +// Copyright (C) 2009-2026 Nicola Asuni - Tecnick.com LTD | |
| 11 | 11 | // |
| 12 | 12 | // This file is part of TCPDF software library. |
| 13 | 13 | // |
| 14 | 14 | // TCPDF is free software: you can redistribute it and/or modify it |
| @@ -21,9 +21,9 @@ | ||
| 21 | 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 22 | 22 | // See the GNU Lesser General Public License for more details. |
| 23 | 23 | // |
| 24 | 24 | // You should have received a copy of the GNU Lesser General Public License |
| 25 | -// along with TCPDF. If not, see <http://www.gnu.org/licenses/>. | |
| 25 | +// along with TCPDF. If not, see <https://www.gnu.org/licenses/>. | |
| 26 | 26 | // |
| 27 | 27 | // See LICENSE.TXT file for more information. |
| 28 | 28 | // ------------------------------------------------------------------- |
| 29 | 29 | // |
| @@ -52,9 +52,9 @@ | ||
| 52 | 52 | /** |
| 53 | 53 | * Array representation of barcode. |
| 54 | 54 | * @protected |
| 55 | 55 | */ |
| 56 | - protected $barcode_array = false; | |
| 56 | + protected $barcode_array = array(); | |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * This is the class constructor. |
| 60 | 60 | * Return an array representations for 2D barcodes:<ul> |
| @@ -61,10 +61,10 @@ | ||
| 61 | 61 | * <li>$arrcode['code'] code to be printed on text label</li> |
| 62 | 62 | * <li>$arrcode['num_rows'] required number of rows</li> |
| 63 | 63 | * <li>$arrcode['num_cols'] required number of columns</li> |
| 64 | 64 | * <li>$arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)</li></ul> |
| 65 | - * @param $code (string) code to print | |
| 66 | - * @param $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul> | |
| 65 | + * @param string $code code to print | |
| 66 | + * @param string $type type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parameters are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul> | |
| 67 | 67 | */ |
| 68 | 68 | public function __construct($code, $type) { |
| 69 | 69 | $this->setBarcode($code, $type); |
| 70 | 70 | } |
| @@ -78,11 +78,11 @@ | ||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Send barcode as SVG image object to the standard output. |
| 82 | - * @param $w (int) Width of a single rectangle element in user units. | |
| 83 | - * @param $h (int) Height of a single rectangle element in user units. | |
| 84 | - * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). | |
| 82 | + * @param int $w Width of a single rectangle element in user units. | |
| 83 | + * @param int $h Height of a single rectangle element in user units. | |
| 84 | + * @param string $color Foreground color (in SVG format) for bar elements (background is transparent). | |
| 85 | 85 | * @public |
| 86 | 86 | */ |
| 87 | 87 | public function getBarcodeSVG($w=3, $h=3, $color='black') { |
| 88 | 88 | // send headers |
| @@ -98,11 +98,11 @@ | ||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Return a SVG string representation of barcode. |
| 102 | - * @param $w (int) Width of a single rectangle element in user units. | |
| 103 | - * @param $h (int) Height of a single rectangle element in user units. | |
| 104 | - * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). | |
| 102 | + * @param int $w Width of a single rectangle element in user units. | |
| 103 | + * @param int $h Height of a single rectangle element in user units. | |
| 104 | + * @param string $color Foreground color (in SVG format) for bar elements (background is transparent). | |
| 105 | 105 | * @return string SVG code. |
| 106 | 106 | * @public |
| 107 | 107 | */ |
| 108 | 108 | public function getBarcodeSVGcode($w=3, $h=3, $color='black') { |
| @@ -134,11 +134,11 @@ | ||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Return an HTML representation of barcode. |
| 138 | - * @param $w (int) Width of a single rectangle element in pixels. | |
| 139 | - * @param $h (int) Height of a single rectangle element in pixels. | |
| 140 | - * @param $color (string) Foreground color for bar elements (background is transparent). | |
| 138 | + * @param int $w Width of a single rectangle element in pixels. | |
| 139 | + * @param int $h Height of a single rectangle element in pixels. | |
| 140 | + * @param string $color Foreground color for bar elements (background is transparent). | |
| 141 | 141 | * @return string HTML code. |
| 142 | 142 | * @public |
| 143 | 143 | */ |
| 144 | 144 | public function getBarcodeHTML($w=10, $h=10, $color='black') { |
| @@ -163,11 +163,11 @@ | ||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * Send a PNG image representation of barcode (requires GD or Imagick library). |
| 167 | - * @param $w (int) Width of a single rectangle element in pixels. | |
| 168 | - * @param $h (int) Height of a single rectangle element in pixels. | |
| 169 | - * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). | |
| 167 | + * @param int $w Width of a single rectangle element in pixels. | |
| 168 | + * @param int $h Height of a single rectangle element in pixels. | |
| 169 | + * @param array $color RGB (0-255) foreground color for bar elements (background is transparent). | |
| 170 | 170 | * @public |
| 171 | 171 | */ |
| 172 | 172 | public function getBarcodePNG($w=3, $h=3, $color=array(0,0,0)) { |
| 173 | 173 | $data = $this->getBarcodePngData($w, $h, $color); |
| @@ -183,12 +183,12 @@ | ||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Return a PNG image representation of barcode (requires GD or Imagick library). |
| 187 | - * @param $w (int) Width of a single rectangle element in pixels. | |
| 188 | - * @param $h (int) Height of a single rectangle element in pixels. | |
| 189 | - * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). | |
| 190 | - * @return image or false in case of error. | |
| 187 | + * @param int $w Width of a single rectangle element in pixels. | |
| 188 | + * @param int $h Height of a single rectangle element in pixels. | |
| 189 | + * @param array $color RGB (0-255) foreground color for bar elements (background is transparent). | |
| 190 | + * @return string|Imagick|false image or false in case of error. | |
| 191 | 191 | * @public |
| 192 | 192 | */ |
| 193 | 193 | public function getBarcodePngData($w=3, $h=3, $color=array(0,0,0)) { |
| 194 | 194 | // calculate image size |
| @@ -237,9 +237,11 @@ | ||
| 237 | 237 | } else { |
| 238 | 238 | ob_start(); |
| 239 | 239 | imagepng($png); |
| 240 | 240 | $imagedata = ob_get_clean(); |
| 241 | - imagedestroy($png); | |
| 241 | + if (PHP_VERSION_ID < 80000) { | |
| 242 | + imagedestroy($png); | |
| 243 | + } | |
| 242 | 244 | return $imagedata; |
| 243 | 245 | } |
| 244 | 246 | } |
| 245 | 247 | |
| @@ -244,11 +246,11 @@ | ||
| 244 | 246 | } |
| 245 | 247 | |
| 246 | 248 | /** |
| 247 | 249 | * Set the barcode. |
| 248 | - * @param $code (string) code to print | |
| 249 | - * @param $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul> | |
| 250 | - * @return array | |
| 250 | + * @param string $code code to print | |
| 251 | + * @param string $type type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parameters are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul> | |
| 252 | + * @return void | |
| 251 | 253 | */ |
| 252 | 254 | public function setBarcode($code, $type) { |
| 253 | 255 | $mode = explode(',', $type); |
| 254 | 256 | $qrtype = strtoupper($mode[0]); |
| @@ -337,9 +339,9 @@ | ||
| 337 | 339 | $this->barcode_array['code'] = $code; |
| 338 | 340 | break; |
| 339 | 341 | } |
| 340 | 342 | default: { |
| 341 | - $this->barcode_array = false; | |
| 343 | + $this->barcode_array = array(); | |
| 342 | 344 | } |
| 343 | 345 | } |
| 344 | 346 | } |
| 345 | 347 | } // end of class |