| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Posprint\Printers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Daruma class for POS printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * Model: DR700 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  | final class Daruma extends DefaultPrinter implements PrinterInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * List all available code pages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     protected $aCodePage = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         'ISO8859-1' => array('conv' => 'ISO8859-1', 'table' => '0', 'desc' => 'ISO8859-1: Latin1'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * List all available region pages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     protected $aRegion = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         'LATIN', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * List all avaiable fonts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     protected $aFont = array(0 => 'normal', 1 => 'elite'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * Selected internal font. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     protected $font = 'normal'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * Seleted code page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * Defined in printer class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     protected $codepage = 'ISO8859-1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * Acceptable barcodes list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     protected $barcode1Dlist = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         'EAN13' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         'EAN8' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         'S25' => 3, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         'I25' => 4, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         'CODE128' => 5, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         'CODE39' => 6, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         'CODE93' => 7, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         'UPC_A' => 8, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         'CODABAR' => 9, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         'MSI' => 10, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         'CODE11' => 11 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * List of supported models | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     protected $modelList = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         'DR600', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         'DR700' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * Selected model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     protected $printerModel = 'DR700'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     //public function __construct(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     //public function defaultCodePage(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     //public function defaultRegionPage(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     //public function defaultFont(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     //public function defaultModel(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     //public function initialize(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * Select printer mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @param string $mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     public function setPrintMode($mode = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     //public function setCodePage(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * Set a region page. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * The numeric key of array $this->aRegion is the command parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @param string $region | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     public function setRegionPage($region = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * Set a printer font | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * If send a valid font name will set the printer otherelse a default font is selected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      *     ESC ! n | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      *        n (BIT)           FUNÇÃO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      *            0 ..... 0      fonte normal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      *                    1      fonte elite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      *            3 ..... 0      desliga enfatizado | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      *                    1      liga enfatizado | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      *            4 ..... 0      desliga dupla altura | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      *                    1      liga dupla altura | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      *            5 ..... 0      desliga expandido | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      *                    1      liga expandido | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      *            7 ..... 0      desliga sublinhado | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      *                    1      liga sublinhado | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @param string $font | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function setFont($font = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $font = $this->defaultFont($font); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         $fn = array_keys($this->aFont, $font, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $mode = $fn[0] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |                 + (2**3 * $this->boldMode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 + (2**4 * $this->doubleHeight) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                 + (2**5 * $this->expandedMode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 + (2**7 * $this->underlineMode); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         $this->buffer->write(self::ESC.'!'.chr($mode)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * Set emphasys mode on or off. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     public function setBold() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $this->boldMode = ! $this->boldMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         if ($this->boldMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             $this->buffer->write(self::ESC . 'E'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             $this->buffer->write(self::ESC . 'F'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * Set Italic mode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * Apenas para V.02.20.00 ou superior. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     public function setItalic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $n = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         if ($this->italicMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             $n = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         $this->italicMode = ! $this->italicMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $this->buffer->write(self::ESC . '4' .chr($n)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * Set underline mode on or off. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     public function setUnderlined() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $this->underlineMode = ! $this->underlineMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $this->buffer->write(self::ESC . '-'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      * Set or unset condensed mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     public function setCondensed() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $this->condensedMode = ! $this->condensedMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         if ($this->condensedMode) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             $this->buffer->write(self::SI); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             $this->buffer->write(self::DC2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * Set or unset expanded mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * @param integer $size not used | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     public function setExpanded($size = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $this->expandedMode = ! $this->expandedMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $this->buffer->write(self::ESC . 'W'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * Aligns all data in one line to the selected layout in standard mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * L - left  C - center  R - rigth | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * OBS: O comando de justificação de texto desliga as configurações de margem. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      *      Apenas para V.02.20.00 ou superior. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @param string $align | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     public function setAlign($align = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         if (is_null($align)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |             $align = 'L'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $value = strtoupper($align); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         switch ($value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             case 'C': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 $mode = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             case 'R': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                 $mode = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                 $mode = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         $this->buffer->write(self::ESC . 'j' . chr($mode)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * Turns white/black reverse print On or Off for characters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     public function setReverseColors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |      * Set rotate 90 degrees. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |     public function setRotate90() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      * Set horizontal and vertical motion units | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |      * $horizontal => character spacing 1/x" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |      * $vertical => line spacing 1/y". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |      * DLE A x y | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |      * Ajusta a unidade de movimento horizontal e vertical para aproximadamente | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |      *   25.4/x mm {1/x"} e 25.4/y mm {1/y"}. A unidade horizontal (x) não é utilizada | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |      * na impressora. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |      *   Faixa: 0 ≤ x ≤ 255 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |      *          0 ≤ y ≤ 255 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      * Padrão: x = 200 (sem uso na impressora) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      *         y = 400 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |      * Quando x e y são igual a zero, o valor padrão é carregado. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |      * @param int $horizontal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |      * @param int $vertical | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     public function setSpacing($horizontal = 30, $vertical = 30) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         $horizontal = self::validateInteger($horizontal, 0, 255, 30); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         $vertical = self::validateInteger($vertical, 0, 255, 30); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         $this->buffer->write(self::DLE.'A'.chr($horizontal).chr($vertical)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |      * Set right-side character spacing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |      * 0 ≤ n ≤ 255 => 1/x". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |      * @param int $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     public function setCharSpacing($value = 3) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |         //not used for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |     //public function setParagraph(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |     //public function text(); vide default | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |      * Prints data and feeds paper n lines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |      * ESC d n Prints data and feeds paper n lines. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      * @param integer $lines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     public function lineFeed($lines = 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         $lines = self::validateInteger($lines, 0, 255, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         for ($lin = 1; $lin <= $lines; $lin++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             $this->buffer->write(self::LF); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     //public function dotFeed(); vide default | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * Insert a image. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * DLE X m xL xH yL yH d1....dk | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      *  m   Mode    Vertical Dot Density    Horizontal Dot Density | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      *  0 Normal         200 dpi                200 dpi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      *  1 Double-width   200 dpi                100 dpi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |      *  2 Double-height  100 dpi                200 dpi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |      *  3 Quadruple      100 dpi                100 dpi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |      * @param  string $filename Path to image file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |      * @param  float  $width | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |      * @param  float  $height | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |      * @param  int    $size     0-normal 1-Double Width 2-Double Heigth 3-Quadruple | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * @throws RuntimeException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     public function putImage($filename = '', $width = null, $height = null, $size = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |             $img = new Graphics($filename, $width, $height); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |         } catch (RuntimeException $e) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |             throw new RuntimeException($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         } catch (InvalidArgumentException $e) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |             throw new RuntimeException($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         $size = self::validateInteger($size, 0, 3, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |         $this->buffer->write(self::DLE . 'X' . chr($size) . $imgHeader . $img->getRasterImage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      * Generate a pulse, for opening a cash drawer if one is connected. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |      * @param int $pin    not for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |      * @param int $on_ms  not for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |      * @param int $off_ms not for this printer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |     public function pulse($pin = 0, $on_ms = 120, $off_ms = 240) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         $this->buffer->write(self::ESC . 'p'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |      * Cut the paper. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |      * @param int $mode  FULL or PARTIAL. not for this printer. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |      * @param int $lines Number of lines to feed after cut | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     public function cut($mode = 'PARTIAL', $lines = 3) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $this->buffer->write(self::ESC.'m'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $this->lineFeed($lines); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |      * Implements barcodes 1D | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |      * ESC b n1 n2 n3 n4 s1...sn NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |      *  n1 – tipo do código a ser impresso | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |      *      EAN13 1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |      *      EAN8 2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |      *      S2OF5 3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |      *      I2OF5 4 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |      *      CODE128 5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |      *      CODE39 6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |      *      CODE93 7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |      *      UPC_A 8 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |      *      CODABAR 9 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |      *      MSI 10 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |      *      CODE11 11 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |      *  n2 – largura da barra. De 2 a 5. Se 0, é usado 2. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |      *  n3 – altura da barra. De 50 a 200. Se 0, é usado 50. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |      *  n4 – se 1, imprime o código abaixo das barras | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |      *  s1...sn – string contendo o código. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |      *      EAN-13: 12 dígitos de 0 a 9 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |      *      EAN–8: 7 dígitos de 0 a 9 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |      *      UPC–A: 11 dígitos de 0 a 9 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |      *      CODE 39 : Tamanho variável. 0-9, A-Z, '-', '.', '%', '/', '$', ' ', '+' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |      *      O caracter '*' de start/stop é inserido automaticamente. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |      *      Sem dígito de verificação MOD 43 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |      *      CODE 93: Tamanho variável. 0-9, A-Z, '-', '.', ' ', '$', '/', '+', '%' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |      *      O caracter '*' de start/stop é inserido automaticamente. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |      *      CODABAR: tamanho variável. 0 - 9, '$', '-', ':', '/', '.', '+' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |      *      Existem 4 diferentes caracteres de start/stop: A, B, C, and D que são | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |      *      usados em pares e não podem aparecer em nenhum outro lugar do código. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |      *      Sem dígito de verificação | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |      *      CODE 11: Tamanho variável. 0 a 9 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |      *      Checksum de dois caracteres. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |      *      CODE 128: Tamanho variável. Todos os caracteres ASCII. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |      *      Interleaved 2 of 5: tamanho sempre par. 0 a 9. Sem dígito de verificação | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |      *      Standard 2 of 5 (Industrial): 0 a 9. Sem dígito de verificação | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |      *      MSI/Plessey: tamanho variável. 0 - 9. 1 dígito de verificação | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |      * @param int    $type        Default CODE128 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |      * @param int    $height | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |      * @param int    $lineWidth | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |      * @param string $txtPosition | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |      * @param string $txtFont | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |      * @param string $data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |     public function barcode( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |         $data = '123456', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |         $type = 'CODE128', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         $height = 162, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |         $lineWidth = 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         $txtPosition = 'none', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |         $txtFont = '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |         if (! $data = Barcodes\Barcode1DAnalysis::validate($data, $type)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |             throw new \InvalidArgumentException('Data or barcode type is incorrect.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         if (! array_key_exists($type, $this->barcode1Dlist)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |             throw new \InvalidArgumentException('This barcode type is not listed.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         $id = $this->barcode1Dlist[$type]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         $height = self::validateInteger($height, 50, 200, 50); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |         $lineWidth = self::validateInteger($lineWidth, 2, 5, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         $n4 = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         if ($txtPosition != 'none') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |             $n4 = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         $this->buffer->write(self::ESC . 'b' . chr($id) . chr($lineWidth) . chr($height) . chr($n4) . $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |      * Print QR Code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |      * [ESC] <129> <–Size><+Size> <Width> <Ecc> <D001> <D002> . . . <Dnnn> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |      * Size inclui os 2 bytes de controle | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |      *    Size ≤ 402 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |      *    nnn = Size – 2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |      *   Largura do módulo (Width): 0, 4 ≤ Width ≤ 7 ( =0 para default = 5) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |      *   Redundância (ECC): 0, M, Q, H ( =0 para cálculo automático) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |      * Apenas para V.02.50.00 ou superior. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |      * @param string $data   Dados a serem inseridos no QRCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |      * @param string $level  Nivel de correção L,M,Q ou H | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |      * @param int    $modelo modelo de QRCode none | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |      * @param int    $wmod   largura da barra 4 ~ 7 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 441 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 442 |  |  |     public function barcodeQRCode($data = '', $level = 'L', $modelo = 2, $wmod = 4) | 
            
                                                                        
                            
            
                                    
            
            
                | 443 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 444 |  |  |         $len = strlen($data); | 
            
                                                                        
                            
            
                                    
            
            
                | 445 |  |  |         $size = $len + 2; | 
            
                                                                        
                            
            
                                    
            
            
                | 446 |  |  |         if ($size > 402) { | 
            
                                                                        
                            
            
                                    
            
            
                | 447 |  |  |             return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 448 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 449 |  |  |         $nH = round($size/256, 0); | 
            
                                                                        
                            
            
                                    
            
            
                | 450 |  |  |         $nL = $size%256; | 
            
                                                                        
                            
            
                                    
            
            
                | 451 |  |  |         if ($wmod > 7 || $wmod < 4) { | 
            
                                                                        
                            
            
                                    
            
            
                | 452 |  |  |             $wmod = 5; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 453 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 454 |  |  |         //set error correction level | 
            
                                                                        
                            
            
                                    
            
            
                | 455 |  |  |         $level = strtoupper($level); | 
            
                                                                        
                            
            
                                    
            
            
                | 456 |  |  |         switch ($level) { | 
            
                                                                        
                            
            
                                    
            
            
                | 457 |  |  |             case 'M': | 
            
                                                                        
                            
            
                                    
            
            
                | 458 |  |  |             case 'Q': | 
            
                                                                        
                            
            
                                    
            
            
                | 459 |  |  |             case 'H': | 
            
                                                                        
                            
            
                                    
            
            
                | 460 |  |  |                 $ecc = $level; | 
            
                                                                        
                            
            
                                    
            
            
                | 461 |  |  |                 break; | 
            
                                                                        
                            
            
                                    
            
            
                | 462 |  |  |             default: | 
            
                                                                        
                            
            
                                    
            
            
                | 463 |  |  |                 $ecc = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 464 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 465 |  |  |         $this->buffer->write(self::ESC . chr(129) . chr($nL) . chr($nH) . chr($w) . $ecc . $data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 466 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |     //public function send(); vide DefultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |     //public function close(); vide DefaultPrinter | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 469 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 470 |  |  |  | 
            
                        
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.