source-class-Com.Tecnick.Barcode.Barcode

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Exceptions

  1: <?php
  2: /**
  3:  * Barcode.php
  4:  *
  5:  * @since       2015-02-21
  6:  * @category    Library
  7:  * @package     Barcode
  8:  * @author      Nicola Asuni <info@tecnick.com>
  9:  * @copyright   2015-2016 Nicola Asuni - Tecnick.com LTD
 10:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
 11:  * @link        https://github.com/tecnickcom/tc-lib-barcode
 12:  *
 13:  * This file is part of tc-lib-barcode software library.
 14:  */
 15: 
 16: namespace Com\Tecnick\Barcode;
 17: 
 18: use \Com\Tecnick\Barcode\Exception as BarcodeException;
 19: 
 20: /**
 21:  * Com\Tecnick\Barcode\Barcode
 22:  *
 23:  * Barcode Barcode class
 24:  *
 25:  * @since       2015-02-21
 26:  * @category    Library
 27:  * @package     Barcode
 28:  * @author      Nicola Asuni <info@tecnick.com>
 29:  * @copyright   2010-2016 Nicola Asuni - Tecnick.com LTD
 30:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
 31:  * @link        https://github.com/tecnickcom/tc-lib-barcode
 32:  */
 33: class Barcode
 34: {
 35:     /**
 36:      * Array containing the map between the barcode type and correspondent class
 37:      *
 38:      * @var array
 39:      */
 40:     protected static $typeclass = array(
 41:         'C128A'      => 'Linear\\CodeOneTwoEight\\A',        // CODE 128 A
 42:         'C128B'      => 'Linear\\CodeOneTwoEight\\B',        // CODE 128 B
 43:         'C128C'      => 'Linear\\CodeOneTwoEight\\C',        // CODE 128 C
 44:         'C128'       => 'Linear\\CodeOneTwoEight',           // CODE 128
 45:         'C39E+'      => 'Linear\\CodeThreeNineExtCheck',     // CODE 39 EXTENDED + CHECKSUM
 46:         'C39E'       => 'Linear\\CodeThreeNineExt',          // CODE 39 EXTENDED
 47:         'C39+'       => 'Linear\\CodeThreeNineCheck',        // CODE 39 + CHECKSUM
 48:         'C39'        => 'Linear\\CodeThreeNine',             // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
 49:         'C93'        => 'Linear\\CodeNineThree',             // CODE 93 - USS-93
 50:         'CODABAR'    => 'Linear\\Codabar',                   // CODABAR
 51:         'CODE11'     => 'Linear\\CodeOneOne',                // CODE 11
 52:         'EAN13'      => 'Linear\\EanOneThree',               // EAN 13
 53:         'EAN2'       => 'Linear\\EanTwo',                    // EAN 2-Digits UPC-Based Extension
 54:         'EAN5'       => 'Linear\\EanFive',                   // EAN 5-Digits UPC-Based Extension
 55:         'EAN8'       => 'Linear\\EanEight',                  // EAN 8
 56:         'I25+'       => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM
 57:         'I25'        => 'Linear\\InterleavedTwoOfFive',      // Interleaved 2 of 5
 58:         'IMB'        => 'Linear\\Imb',                       // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
 59:         'IMBPRE'     => 'Linear\\ImbPre',                    // IMB - Intelligent Mail Barcode pre-processed
 60:         'KIX'        => 'Linear\\KlantIndex',                // KIX (Klant index - Customer index)
 61:         'MSI+'       => 'Linear\\MsiCheck',                  // MSI + CHECKSUM (modulo 11)
 62:         'MSI'        => 'Linear\\Msi',                       // MSI (Variation of Plessey code)
 63:         'PHARMA2T'   => 'Linear\\PharmaTwoTracks',           // PHARMACODE TWO-TRACKS
 64:         'PHARMA'     => 'Linear\\Pharma',                    // PHARMACODE
 65:         'PLANET'     => 'Linear\\Planet',                    // PLANET
 66:         'POSTNET'    => 'Linear\\Postnet',                   // POSTNET
 67:         'RMS4CC'     => 'Linear\\RoyalMailFourCc',           // RMS4CC (Royal Mail 4-state Customer Bar Code)
 68:         'S25+'       => 'Linear\\StandardTwoOfFiveCheck',    // Standard 2 of 5 + CHECKSUM
 69:         'S25'        => 'Linear\\StandardTwoOfFive',         // Standard 2 of 5
 70:         'UPCA'       => 'Linear\\UpcA',                      // UPC-A
 71:         'UPCE'       => 'Linear\\UpcE',                      // UPC-E
 72:         'DATAMATRIX' => 'Square\\Datamatrix',                // DATAMATRIX (ISO/IEC 16022)
 73:         'PDF417'     => 'Square\\PdfFourOneSeven',           // PDF417 (ISO/IEC 15438:2006)
 74:         'QRCODE'     => 'Square\\QrCode',                    // QR-CODE
 75:         'LRAW'       => 'Linear\\Raw',                       // 1D RAW MODE (comma-separated rows of 01 strings)
 76:         'SRAW'       => 'Square\\Raw',                       // 2D RAW MODE (comma-separated rows of 01 strings)
 77:     );
 78: 
 79:     /**
 80:      * Get the list of supported Barcode types
 81:      *
 82:      * @return array
 83:      */
 84:     public function getTypes()
 85:     {
 86:         return array_keys(self::$typeclass);
 87:     }
 88: 
 89:     /**
 90:      * Get the barcode object
 91:      *
 92:      * @param string $type    Barcode type
 93:      * @param string $code    Barcode content
 94:      * @param int    $width   Barcode width in user units (excluding padding).
 95:      *                        A negative value indicates the multiplication factor for each column.
 96:      * @param int    $height  Barcode height in user units (excluding padding).
 97:      *                        A negative value indicates the multiplication factor for each row.
 98:      * @param string $color   Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax)
 99:      * @param array  $padding Additional padding to add around the barcode (top, right, bottom, left) in user units.
100:      *                        A negative value indicates the multiplication factor for each row or column.
101:      *
102:      * @return Type
103:      *
104:      * @throws BarcodeException in case of error
105:      */
106:     public function getBarcodeObj(
107:         $type,
108:         $code,
109:         $width = -1,
110:         $height = -1,
111:         $color = 'black',
112:         $padding = array(0, 0, 0, 0)
113:     ) {
114:         // extract extra parameters (if any)
115:         $params = explode(',', $type);
116:         $type = array_shift($params);
117:         
118:         if (empty(self::$typeclass[$type])) {
119:             throw new BarcodeException('Unsupported barcode type: '.$type);
120:         }
121:         $bclass = '\\Com\\Tecnick\\Barcode\\Type\\'.self::$typeclass[$type];
122:         return new $bclass($code, $width, $height, $color, $params, $padding);
123:     }
124: }
125: 
 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy