| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Posprint\Printers\Bematech; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Bematech class for POS printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * Model: MP 4200TH | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @category   NFePHP | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @package    Posprint | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @copyright  Copyright (c) 2016 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @license    http://www.gnu.org/licenses/lesser.html LGPL v3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @author     Roberto L. Machado <linux.rlm at gmail dot com> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @link       http://github.com/nfephp-org/posprint for the canonical source repository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Posprint\Printers\DefaultPrinter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Posprint\Printers\PrinterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | class Bematech extends DefaultPrinter implements PrinterInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * List all available code pages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     protected $aCodePage = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         'CP437' => array('conv' => '437', 'table' => '3', 'desc' => 'PC437: USA, Standard Europe'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         'CP850' => array('conv' => '850', 'table' => '2', 'desc' => 'PC850: Multilingual'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         'CP858' => array('conv' => '858', 'table' => '5', 'desc' => 'PC858: Multilingual'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         'CP860' => array('conv' => '860', 'table' => '4', 'desc' => 'PC860: Portuguese'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         'CP864' => array('conv' => '864', 'table' => '7', 'desc' => 'PC864: Arabic'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'CP866' => array('conv' => '866', 'table' => '6', 'desc' => 'PC866: Cyrillic'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'UTF8'  => array('conv' => 'UTF8', 'table' => '8', 'desc' => 'UTF-8: Unicode') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * List all available region pages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     protected $aRegion = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         'LATIN' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * Seleted printer mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 1 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected $printerMode = 'ESCBEMA'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * List all avaiable fonts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     protected $aFont = array(0 => 'C', 1 => 'D'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * Selected internal font. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     protected $font = 'C'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * Seleted code page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * Defined in printer class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     protected $codepage = 'CP850'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * Acceptable barcodes list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     protected $barcode1Dlist = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         'UPC_A' => 65, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         'UPC_E' => 66, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         'EAN13' => 67, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         'EAN8' => 68, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         'CODE39' => 69, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         'I25' => 70, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         'CODABAR' => 71, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         'CODE93' => 72, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         'CODE128' => 73, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         'ISBN' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         'MSI' => null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * List of supported models | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     protected $modelList = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         '4200TH' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * Selected model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     protected $printerModel = '4200TH'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     //public function __construct(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     //public function defaultCodePage(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     //public function defaultRegionPage(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     //public function defaultFont(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     //public function defaultModel(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     //public function initialize(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * Select printer mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param string $mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public function setPrintMode($mode = 'ESCBEMA') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         if ($mode != $this->printerMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             switch ($mode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                 case 'ESCBEMA': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                     $this->printerMode = 'ESCBEMA'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                     break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                 default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                     $this->printerMode = 'ESCPOS'; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 121 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |         $nmod = 0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |             $nmod = 1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |         $this->buffer->write(self::GS . chr(249) . chr(53) . $nmode); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |      * Set a codepage table in printer. | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |      * @param string $codepage | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |     public function setCodePage($codepage = null) | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |             parent::setCodePage($codepage); | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |         $codepage = $this->defaultCodePage($codepage); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |         $this->buffer->write(self::GS . chr(249) . chr(55) . chr($this->charsetTableNum)); | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |      * Set a region page. | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |      * The numeric key of array $this->aRegion is the command parameter. | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |      * @param string $region | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |     public function setRegionPage($region = null) | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |         //not used for this printer | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |      * Set a printer font | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |      * If send a valid font name will set the printer otherelse a default font is selected | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |      * @param string $font | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |     public function setFont($font = null) | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |             parent::setFont($codepage); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |      * Set emphasys mode on or off. | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |     public function setBold() | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |             parent::setBold(); | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |         $this->boldMode = ! $this->boldMode; | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |         if ($this->boldMode) { | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  |             $this->buffer->write(self::ESC . 'E'); | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |             $this->buffer->write(self::ESC . 'F'); | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |      * Set Italic mode | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |     public function setItalic() | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  |         $this->italicMode = ! $this->italicMode; | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |         if ($this->italicMode) { | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  |             $this->buffer->write(self::ESC . '4'); | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  |             $this->buffer->write(self::ESC . '5'); | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  |     //public function setUnderlined(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  |      * Set or unset condensed mode. | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     public function setCondensed() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         $this->condensedMode = ! $this->condensedMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         if ($this->condensedMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             $this->buffer->write(self::SI); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             $this->buffer->write(self::DC2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      * Set or unset expanded mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |      * @param integer $size not used | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     public function setExpanded($size = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         $this->expandedMode = ! $this->expandedMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         $n = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         if ($this->expandedMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             $n = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $this->buffer->write(self::ESC . 'W' . chr($n)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     //public function setAlign(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |      * Turns white/black reverse print On or Off for characters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     public function setReverseColors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             parent::reverseColors(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      * Set rotate 90 degrees. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     public function setRotate90() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             parent::setRotate90(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      * Set horizontal and vertical motion units | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      * $horizontal => character spacing 1/x" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |      * $vertical => line spacing 1/y". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |     public function setSpacing($horizontal = 30, $vertical = 30) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |      * Set right-side character spacing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |      * 0 ≤ n ≤ 255 => 1/x". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      * @param int $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     public function setCharSpacing($value = 3) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     //public function setParagraph(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     //public function text(); vide default | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      * Prints data and feeds paper n lines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |      * ESC d n Prints data and feeds paper n lines. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |      * @param integer $lines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |     public function lineFeed($lines = 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |             parent::lineFeed($lines); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         $lines = self::validateInteger($lines, 0, 255, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         for ($lin = 1; $lin <= $lines; $lin++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             $this->buffer->write(self::LF); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |     //public function dotFeed(); vide default | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * Put a image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * GS v0 m xL xH yL yH d1 ... dk | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @param string $filename | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      * @param intger $width | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      * @param integer $height | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |      * @param integer $size resolution relation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |      * @throws RuntimeException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |     public function putImage($filename = '', $width = null, $height = null, $size = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |             $img = new Graphics($filename, $width, $height); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |         } catch (RuntimeException $e) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |             throw new RuntimeException($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |         } catch (InvalidArgumentException $e) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             throw new RuntimeException($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         $size = self::validateInteger($size, 0, 3, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |         //get xL xH yL yH | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         //send graphics command to printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         $this->buffer->write(self::GS.'v0'.chr($size).$imgHeader.$img->getRasterImage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |      * Generate a pulse, for opening a cash drawer if one is connected. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * @param int $pin    0 or 1, for pin 2 or pin 5 kick-out connector respectively. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      * @param int $on_ms  pulse ON time, in milliseconds. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |      * @param int $off_ms pulse OFF time, in milliseconds. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     public function pulse($pin = 0, $on_ms = 120, $off_ms = 240) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |             parent::pulse($pin, $on_ms, $off_ms); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |         $on_ms = self::validateInteger($on_ms, 50, 250, 50); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         if ($pin == 0 || $pin == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |             $this->buffer->write(self::ESC.'v'. chr($on_ms)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |             $this->buffer->write(self::ESC. chr(128) . chr($on_ms)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |      * Cut the paper. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      * @param int $mode  FULL or PARTIAL. If not specified, FULL will be used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |      * @param int $lines Number of lines to feed after cut | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     public function cut($mode = 'PARTIAL', $lines = 3) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |             parent::cut($mode, $lines); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |         $lines = self::validateInteger($lines, 1, 10, 3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         if ($mode == 'FULL') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |             $this->buffer->write(self::ESC.'w'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |             $this->buffer->write(self::ESC.'m'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $this->lineFeed($lines); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |      * Implements barcodes 1D | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |      * @param int    $type        Default CODE128 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |      * @param int    $height | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |      * @param int    $lineWidth | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |      * @param string $txtPosition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |      * @param string $txtFont | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |      * @param string $data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |     public function barcode( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |         $data = '123456', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         $type = 'CODE128', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         $height = 162, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         $lineWidth = 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |         $txtPosition = 'none', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |         $txtFont = '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |         if ($this->printerMode == 'ESCPOS') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |             parent::barcode($data, $type, $height, $lineWidth, $txtPosition, $txtFont); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         if (! $data = Barcodes\Barcode1DAnalysis::validate($data, $type)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |             throw new \InvalidArgumentException('Data or barcode type is incorrect.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         if (! array_key_exists($type, $this->barcode1Dlist)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             throw new \InvalidArgumentException('This barcode type is not listed.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         $id = $this->barcode1Dlist[$type]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |         $height = self::validateInteger($height, 50, 200, 50); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         $lineWidth = self::validateInteger($lineWidth, 2, 5, 2); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         $n4 = 0; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |         if ($txtPosition != 'none') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |             $n4 = 1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |         switch ($type) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |             case 'UPC_A': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |             case 'UPC_E': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |             case 'EAN13': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |             case 'EAN8': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |             case 'CODE39': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |             case 'I25': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |             case 'CODABAR': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |             case 'CODE93': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             case 'CODE128': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |             case 'ISBN': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |             case 'MSI': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                 //$this->buffer->write(self::ESC); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |      * Imprime o QR Code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |      * @param string $data   Dados a serem inseridos no QRCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |      * @param string $level  Nivel de correção L,M,Q ou H | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |      * @param int    $modelo modelo de QRCode 0 QRCode ou 1 microQR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |      * @param int    $wmod   largura da barra 3 ~ 16 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |     public function barcodeQRCode($data = '', $level = 'M', $modelo = 0, $wmod = 4) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |         $aModels = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         //essa matriz especifica o numero máximo de caracteres alfanumericos que o | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         //modelo de QRCode suporta dependendo no nivel de correção. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         //Cada matriz representa um nivel de correção e cada uma das 40 posições nessas | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |         //matrizes indicam o numero do modelo do QRCode e o numero máximo de caracteres | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |         //alfamunéricos suportados | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |         //Quanto maior o nivel de correção menor é a quantidade de caracteres suportada | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |         $aModels[0]=[25,47,77,114,154,195,224,279,335,395,468,535,619,667, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |             758,854,938,1046,1153,1249,1352,1460,1588,1704,1853,1990,2132, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |             2223,2369,2520,2677,2840,3009,3183,3351,3537,3729,3927,4087,4296]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |         $aModels[1]=[20,38,61,90,122,154,178,221,262,311,366,419,483,528,600, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             656,734,816,909,970,1035,1134,1248,1326,1451,1542,1637,1732,1839, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             1994,2113,2238,2369,2506,2632,2780,2894,3054,3220,3391]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |         $aModels[2]=[16,29,47,67,87,108,125,157,189,221,259,296,352,376,426, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             470,531,574,644,702,742,823,890,963,1041,1094,1172,1263,1322,1429, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |             1499,1618,1700,1787,1867,1966,2071,2181,2298,2420]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         $aModels[3]=[10,20,35,50,64,84,93,122,143,174,200,227,259,283,321,365, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |             408,452,493,557,587,640,672,744,779,864,910,958,1016,1080,1150,1226, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |             1307,1394,1431,1530,1591,1658,1774,1852]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |         //n1 Error correction level (data restoration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |         switch ($level) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |             case 'L': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                 $n1 = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |             case "M": | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |                 $n1 = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |             case "Q": | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |                 $n1 = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |             case "H": | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |                 $n1 = 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |             default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |                 $n1 = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         if ($modelo != 0 && $modelo != 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |             $modelo = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         //se for mucroQR sua capacidade é bem reduzida | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |         if ($modelo == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |             $aModels[0] = [6,14,21]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |             $aModels[1] = [5,11,18]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |             $aModels[2] = [0,0,13]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |             $aModels[3] = [0,0,0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         //n2 Module/cell size in pixels MSB 1 ≤ module size ≤ 127 LSB 0 QR or 1 MicroQR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |         $n2 = $wmod << 1;//shift 1 é o mesmo que multiplicar por 2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |         $n2 += $modelo;//seleciona QRCode ou microQR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |         //comprimento da mensagem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |         $length = strlen($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |         //seleciona matriz de modelos aplicavel pelo nivel de correção | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         $am = $aModels[$n1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |         $i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $flag = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         foreach ($am as $size) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |             //verifica se o tamanho maximo é maior ou igual ao comprimento da mensagem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |             if ($size >= $length) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |                 $flag = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |             $i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |         if (! $flag) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |             throw new InvalidArgumentException( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |                 'O numero de caracteres da mensagem é maior que a capacidade do QRCode' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |         //n3 Version QRCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |         //depende do comprimento dos dados e do nivel de correção | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         $n3 = ($i + 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |         //n4 Encoding modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         //0 – Numeric only              Max. 7,089 characters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         //1 – Alphanumeric              Max. 4,296 characters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         //2 – Binary (8 bits)           Max. 2,953 bytes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         //3 – Kanji, full-width Kana    Max. 1,817 characters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |         $n4 = 1;//sempre será 1 apenas caracteres alfanumericos nesse caso | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |         //n5 e n6 Indicate the number of bytes that will be coded, where total = n5 + n6 x 256, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |         //and total must be less than 7089. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         $n6 = intval($length / 256); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |         $n5 = ($length % 256); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |         $this->buffer->write(self::GS."kQ" . chr($n1) . chr($n2) . chr($n3) . chr($n4) . chr($n5) . chr($n6) . $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 537 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 538 |  |  |  | 
            
                        
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.