├── src ├── lang │ └── .gitkeep ├── views │ └── .gitkeep ├── config │ ├── .gitkeep │ └── config.php ├── migrations │ └── .gitkeep ├── routes.php └── Milon │ └── Barcode │ ├── WrongCheckDigitException.php │ ├── Facades │ ├── DNS2DFacade.php │ └── DNS1DFacade.php │ ├── GS1_128 │ ├── Section.php │ ├── SectionSlicer.php │ ├── Subsets.php │ ├── GS1128.php │ └── AIData.php │ ├── BarcodeServiceProvider.php │ ├── DNS2D.php │ ├── Datamatrix.php │ └── PDF417.php ├── banner.png ├── composer.json ├── readme.md └── LICENSE.TXT /src/lang/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/views/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/config/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/migrations/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milon/barcode/HEAD/banner.png -------------------------------------------------------------------------------- /src/config/config.php: -------------------------------------------------------------------------------- 1 | public_path("/"), 5 | ]; 6 | -------------------------------------------------------------------------------- /src/routes.php: -------------------------------------------------------------------------------- 1 | fixedLength = (bool) $fixedLength; 29 | $this->identifier = $identifier; 30 | $this->value = $value; 31 | } 32 | 33 | public function hasFixedLength() 34 | { 35 | return $this->fixedLength; 36 | } 37 | 38 | function jsonSerialize() 39 | { 40 | return [$this->identifier, $this->value]; 41 | } 42 | 43 | public function __toString() 44 | { 45 | return sprintf('%s%s', $this->identifier, $this->value); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Milon/Barcode/BarcodeServiceProvider.php: -------------------------------------------------------------------------------- 1 | publishes([ 22 | __DIR__.'/../../config/config.php' => config_path('barcode.php'), 23 | ]); 24 | } 25 | 26 | /** 27 | * Register the service provider. 28 | * 29 | * @return void 30 | */ 31 | public function register() { 32 | 33 | $this->app->singleton('DNS1D', function() { 34 | return new DNS1D; 35 | }); 36 | $this->app->singleton('DNS2D', function() { 37 | return new DNS2D; 38 | }); 39 | } 40 | 41 | /** 42 | * Get the services provided by the provider. 43 | * 44 | * @return array 45 | */ 46 | public function provides() { 47 | return array("DNS1D", "DNS2D"); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/Milon/Barcode/Facades/DNS1DFacade.php: -------------------------------------------------------------------------------- 1 | build($sectionData[0], $sectionData[1]); 23 | } 24 | 25 | return $expected; 26 | } 27 | 28 | public function build($identifier, $value) 29 | { 30 | if (array_key_exists($identifier, AIData::$default) === false) { 31 | throw new \LogicException(sprintf('Unknown application identifier %s', $identifier)); 32 | } 33 | 34 | [$minLength, $maxLength, $description] = AIData::$default[$identifier]; 35 | 36 | if (strlen($value) < $minLength || strlen($value) > $maxLength) { 37 | throw new \LogicException($description); 38 | } 39 | 40 | $fixedLength = $minLength === $maxLength; 41 | 42 | return new Section($identifier, $value, $fixedLength); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "milon/barcode", 3 | "description": "Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)", 4 | "keywords": [ 5 | "barcode", 6 | "laravel", 7 | "qrcode", 8 | "QR Code", 9 | "PDF417", 10 | "Datamatrix", 11 | "CODE 39", 12 | "CODE 128", 13 | "EAN", 14 | "CODABAR" 15 | ], 16 | "license": "LGPL-3.0", 17 | "authors": [ 18 | { 19 | "name": "Nuruzzaman Milon", 20 | "email": "contact@milon.im" 21 | } 22 | ], 23 | "require": { 24 | "php": "^7.3 | ^8.0", 25 | "ext-gd": "*", 26 | "illuminate/support": "^7.0|^8.0|^9.0|^10.0 | ^11.0 | ^12.0" 27 | }, 28 | "autoload": { 29 | "psr-0": { 30 | "Milon\\Barcode": "src/" 31 | } 32 | }, 33 | "minimum-stability": "stable", 34 | "config": { 35 | "sort-packages": true 36 | }, 37 | "extra": { 38 | "laravel": { 39 | "providers": [ 40 | "Milon\\Barcode\\BarcodeServiceProvider" 41 | ], 42 | "aliases": { 43 | "DNS1D": "Milon\\Barcode\\Facades\\DNS1DFacade", 44 | "DNS2D": "Milon\\Barcode\\Facades\\DNS2DFacade" 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Milon/Barcode/GS1_128/Subsets.php: -------------------------------------------------------------------------------- 1 | 99, 8 | 'B' => 100, 9 | 'A' => 101, 10 | ]; 11 | 12 | private $mapA = [ 13 | ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', // 9 14 | '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', // 19 15 | '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', // 29 16 | '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', // 39 17 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', // 49 18 | 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', // 59 19 | '\\', ']', '^', '_', // 63 20 | "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", // 69 21 | "\x06", "\x07", "\x08", "\x09", "\x0A", "\x0B", // 75 22 | "\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", // 81 23 | "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", // 87 24 | "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", // 93 25 | "\x1E", "\x1F", // 95 26 | 'FNC_3', 'FNC_2', 'SHIFT_B', 'CODE_C', 'CODE_B', // 100 27 | 'FNC_4', 'FNC_1', 'START_A', 'START_B', 'START_C', // 105 28 | 'STOP', // 106 29 | ]; 30 | 31 | private $mapB = [ 32 | ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', // 9 33 | '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', // 19 34 | '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', // 29 35 | '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', // 39 36 | 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', // 49 37 | 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', // 59 38 | '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', // 69 39 | 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 79 40 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', // 89 41 | 'z', '{', '|', '}', '~', "\x7F", // 95 42 | 'FNC_3', 'FNC_2', 'SHIFT_A', 'CODE_C', 'FNC_4', // 100 43 | 'CODE_A', 'FNC_1', 'START_A', 'START_B', 'START_C', // 105 44 | 'STOP', // 106 45 | ]; 46 | 47 | //C generates the shortest code 48 | private $mapC = [ 49 | "00","01","02","03","04","05","06","07","08","09", 50 | "10","11","12","13","14","15","16","17","18","19", 51 | "20","21","22","23","24","25","26","27","28","29", 52 | "30","31","32","33","34","35","36","37","38","39", 53 | "40","41","42","43","44","45","46","47","48","49", 54 | "50","51","52","53","54","55","56","57","58","59", 55 | "60","61","62","63","64","65","66","67","68","69", 56 | "70","71","72","73","74","75","76","77","78","79", 57 | "80","81","82","83","84","85","86","87","88","89", 58 | "90","91","92","93","94","95","96","97","98","99" 59 | ]; 60 | 61 | public function getSubsetSefault() 62 | { 63 | //C generates the shortest code 64 | return 'C'; 65 | } 66 | 67 | public function getAllSubset() 68 | { 69 | return $this->subsets; 70 | } 71 | 72 | public function get($code) 73 | { 74 | return $this->{"map$code"} ?? $this->mapC; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Milon/Barcode/GS1_128/GS1128.php: -------------------------------------------------------------------------------- 1 | slicer = new SectionSlicer(); 32 | $this->subsets = new Subsets(); 33 | $this->currentSubset = $this->subsets->getSubsetSefault(); 34 | } 35 | 36 | public function generate($barcodeString) 37 | { 38 | $this->binaryCodeOffsets = []; 39 | $this->binaryCodeOffsets[] = 105; //start 40 | $this->binaryCodeOffsets[] = 102; //fcn1 41 | 42 | $sections = $this->slicer->getSections($barcodeString); 43 | $totalSectionsNumber = count($sections); 44 | $i = 1; 45 | 46 | /* @var $section Section */ 47 | foreach ($sections as $section) { 48 | $this->doShit($this->getPairs((string) $section), $barcodeString); 49 | 50 | if ($i++ < $totalSectionsNumber && $section->hasFixedLength() === false) { 51 | $this->binaryCodeOffsets[] = 102; //fcn1 52 | } 53 | } 54 | 55 | $this->binaryCodeOffsets[] = $this->generateChecksum($this->binaryCodeOffsets); 56 | $this->binaryCodeOffsets[] = 106; // STOP 57 | $this->binaryCodeOffsets[] = 107; // TERMINATE 58 | 59 | return array_map(function($i) { return (int) $i; }, $this->binaryCodeOffsets); 60 | } 61 | 62 | /** 63 | * @param $letter 64 | * @param $pair 65 | * @return bool 66 | */ 67 | private function setProperSubset($letter, $pair) 68 | { 69 | if (array_search((string) $pair, $this->getSubsetMap($letter), true)) { 70 | $this->currentSubset = $letter; 71 | $this->binaryCodeOffsets[] = $this->subsets->getAllSubset()[$letter]; 72 | return true; 73 | } 74 | 75 | return false; 76 | } 77 | 78 | /** 79 | * @param $pair 80 | * @param $fullCode 81 | */ 82 | private function checkSubsetMap($pair, $fullCode) 83 | { 84 | if (array_search((string) $pair, $this->getCurrentSubset(), true)) { 85 | return; 86 | } 87 | 88 | foreach (array_keys($this->subsets->getAllSubset()) as $letter) { 89 | if ($this->setProperSubset($letter, $pair)) { 90 | return; 91 | } 92 | } 93 | } 94 | 95 | /** 96 | * @param $array 97 | * @return string (binary) 98 | */ 99 | private function generateChecksum($array) 100 | { 101 | $total = 0; 102 | foreach ($array as $i => $value) { 103 | $multiplier = $i === 0 ? 1 : $i; 104 | $total += $value * $multiplier; 105 | } 106 | 107 | return $total % 103; 108 | } 109 | 110 | /** 111 | * @param $array 112 | * @param $fullCode 113 | */ 114 | private function doShit($array, $fullCode) 115 | { 116 | foreach ($array as $pair) { 117 | $this->checkSubsetMap($pair, $fullCode); 118 | $key = array_search($pair, $this->getCurrentSubset(), true); 119 | $key === false ? $this->doShit(str_split($pair), $fullCode) : $this->binaryCodeOffsets[] = $key; 120 | } 121 | } 122 | 123 | /** 124 | * @param $code 125 | * @return array 126 | */ 127 | private function getPairs($code) 128 | { 129 | return str_split($code, 2); 130 | } 131 | 132 | /** 133 | * @return array 134 | */ 135 | private function getCurrentSubset() 136 | { 137 | return $this->getSubsetMap($this->currentSubset); 138 | } 139 | 140 | private function getSubsetMap($letter) 141 | { 142 | return $this->subsets->get($letter); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | [![Packagist Downloads](https://img.shields.io/packagist/dt/milon/barcode.svg)](https://packagist.org/packages/milon/barcode) 2 | [![Stable version](https://img.shields.io/packagist/v/milon/barcode.svg)](https://packagist.org/packages/milon/barcode) 3 | [![License](https://img.shields.io/packagist/l/milon/barcode.svg)](https://packagist.org/packages/milon/barcode) 4 | 5 | ![Banner](./banner.png) 6 | 7 | This is a barcode generation package inspired by . Actually, I use that package's underline classes for generating barcodes. This package is just a wrapper of that package and adds compatibility with Laravel. 8 | 9 | I used the following classes of that package. 10 | 11 | - src/Milon/Barcode/Datamatrix.php (include/barcodes/datamatrix.php) 12 | - src/Milon/Barcode/DNS1D.php (tcpdf_barcodes_1d.php) 13 | - src/Milon/Barcode/DNS2D.php (tcpdf_barcodes_2d.php) 14 | - src/Milon/Barcode/PDF417.php (include/barcodes/pdf417.php) 15 | - src/Milon/Barcode/QRcode.php (include/barcodes/qrcode.php) 16 | 17 | [Read More on TCPDF website](http://www.tcpdf.org) 18 | 19 | This package relies on [php-gd](http://php.net/manual/en/book.image.php) extension. So, make sure it is installed on your machine. 20 | 21 | ## Installation 22 | 23 | Begin by installing this package through Composer. Just run following command to terminal- 24 | 25 | ```shell script 26 | composer require milon/barcode 27 | ``` 28 | 29 | You can also edit your project's `composer.json` file to require `milon/barcode`. Just make sure you choosed the compatible version of the package from the following table. 30 | 31 | ## Compatibility 32 | 33 | | Laravel Version | Barcode Package Version | 34 | |-----------------|-------------------------| 35 | | 12.* | ^12.0 | 36 | | 11.* | ^11.0 | 37 | | 10.* | ^10.0 | 38 | | 9.* | ^9.0 | 39 | | 8.* | ^8.0 | 40 | | 7.* | ^7.0 | 41 | | 6.* | ^6.0 | 42 | | 5.0 and 5.1 | ^5.1 | 43 | | 4.0, 4.1, 4.2 | ^4.2 | 44 | 45 | ## Configuration 46 | 47 | > If you are using version 6 or above, then the Service Provider and aliases will be published automatically. For prior versions, please follow the below instruction. 48 | 49 | After updating Composer, add the service provider to your `config/app.php` file: 50 | 51 | ```php 52 | 'providers' => [ 53 | // ... 54 | Milon\Barcode\BarcodeServiceProvider::class, 55 | ] 56 | ``` 57 | 58 | For Laravel version 4.*, add the following lines to your `app/config/app.php` file: 59 | 60 | ```php 61 | 'providers' => array( 62 | // ... 63 | 'Milon\Barcode\BarcodeServiceProvider', 64 | ) 65 | ``` 66 | 67 | **Make sure you have write permission to the storage path. By default it sets to `/storage` folder.** 68 | 69 | ```php 70 | 'aliases' => [ 71 | // ... 72 | 'DNS1D' => Milon\Barcode\Facades\DNS1DFacade::class, 73 | 'DNS2D' => Milon\Barcode\Facades\DNS2DFacade::class, 74 | ] 75 | ``` 76 | 77 | For version 4.2 alias will be like this- 78 | 79 | ```php 80 | 'aliases' => array( 81 | // ... 82 | 'DNS1D' => 'Milon\Barcode\Facades\DNS1DFacade', 83 | 'DNS2D' => 'Milon\Barcode\Facades\DNS2DFacade', 84 | ) 85 | ``` 86 | 87 | ## Publishing Configuration 88 | 89 | To customize the barcode settings (e.g., store path), publish the configuration file(s) by running the appropriate command in the terminal: 90 | 91 | ```shell 92 | # Laravel 5.x 93 | php artisan vendor:publish 94 | 95 | # Laravel 4.x 96 | php artisan config:publish milon/barcode 97 | ``` 98 | 99 | ## Usage 100 | 101 | Bar-code generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code) 102 | 103 | generator in html, png , jpeg embedded base64 code and SVG canvas 104 | 105 | ```php 106 | echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T'); 107 | echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T'); 108 | echo 'barcode'; 109 | echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T'); 110 | echo 'barcode'; 111 | echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T'); 112 | echo 'barcode'; 113 | ``` 114 | 115 | ```php 116 | echo DNS1D::getBarcodeSVG('4445645656', 'C39'); 117 | echo DNS2D::getBarcodeHTML('4445645656', 'QRCODE'); 118 | echo DNS2D::getBarcodePNGPath('4445645656', 'PDF417'); 119 | echo DNS2D::getBarcodeSVG('4445645656', 'DATAMATRIX'); 120 | echo 'barcode'; 121 | ``` 122 | 123 | ## Width and Height example 124 | 125 | ```php 126 | echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T',3,33); 127 | echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T',3,33); 128 | echo 'barcode'; 129 | echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T',3,33); 130 | echo 'barcode'; 131 | echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T',3,33); 132 | echo 'barcode'; 133 | ``` 134 | 135 | ## Color 136 | 137 | ```php 138 | echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T',3,33,'green'); 139 | echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T',3,33,'green'); 140 | echo 'barcode'; 141 | echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0)); 142 | echo 'barcode'; 143 | echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0)); 144 | echo 'barcode'; 145 | ``` 146 | 147 | ## Show Text 148 | 149 | ```php 150 | echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T',3,33,'green', true); 151 | echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T',3,33,'green', true); 152 | echo 'barcode'; 153 | echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0), true); 154 | echo 'barcode'; 155 | echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0), true); 156 | echo 'barcode'; 157 | ``` 158 | 159 | ## 2D Barcodes 160 | 161 | ```php 162 | echo DNS2D::getBarcodeHTML('4445645656', 'QRCODE'); 163 | echo DNS2D::getBarcodePNGPath('4445645656', 'PDF417'); 164 | echo DNS2D::getBarcodeSVG('4445645656', 'DATAMATRIX'); 165 | ``` 166 | 167 | ## 1D Barcodes 168 | 169 | ```php 170 | echo DNS1D::getBarcodeHTML('4445645656', 'C39'); 171 | echo DNS1D::getBarcodeHTML('4445645656', 'C39+'); 172 | echo DNS1D::getBarcodeHTML('4445645656', 'C39E'); 173 | echo DNS1D::getBarcodeHTML('4445645656', 'C39E+'); 174 | echo DNS1D::getBarcodeHTML('4445645656', 'C93'); 175 | echo DNS1D::getBarcodeHTML('4445645656', 'S25'); 176 | echo DNS1D::getBarcodeHTML('4445645656', 'S25+'); 177 | echo DNS1D::getBarcodeHTML('4445645656', 'I25'); 178 | echo DNS1D::getBarcodeHTML('4445645656', 'I25+'); 179 | echo DNS1D::getBarcodeHTML('4445645656', 'C128'); 180 | echo DNS1D::getBarcodeHTML('4445645656', 'C128A'); 181 | echo DNS1D::getBarcodeHTML('4445645656', 'C128B'); 182 | echo DNS1D::getBarcodeHTML('4445645656', 'C128C'); 183 | echo DNS1D::getBarcodeHTML('4445645656', 'GS1-128'); 184 | echo DNS1D::getBarcodeHTML('44455656', 'EAN2'); 185 | echo DNS1D::getBarcodeHTML('4445656', 'EAN5'); 186 | echo DNS1D::getBarcodeHTML('4445', 'EAN8'); 187 | echo DNS1D::getBarcodeHTML('4445', 'EAN13'); 188 | echo DNS1D::getBarcodeHTML('4445645656', 'UPCA'); 189 | echo DNS1D::getBarcodeHTML('4445645656', 'UPCE'); 190 | echo DNS1D::getBarcodeHTML('4445645656', 'MSI'); 191 | echo DNS1D::getBarcodeHTML('4445645656', 'MSI+'); 192 | echo DNS1D::getBarcodeHTML('4445645656', 'POSTNET'); 193 | echo DNS1D::getBarcodeHTML('4445645656', 'PLANET'); 194 | echo DNS1D::getBarcodeHTML('4445645656', 'RMS4CC'); 195 | echo DNS1D::getBarcodeHTML('4445645656', 'KIX'); 196 | echo DNS1D::getBarcodeHTML('4445645656', 'IMB'); 197 | echo DNS1D::getBarcodeHTML('4445645656', 'CODABAR'); 198 | echo DNS1D::getBarcodeHTML('4445645656', 'CODE11'); 199 | echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA'); 200 | echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T'); 201 | ``` 202 | 203 | # Running without Laravel 204 | 205 | You can use this library without using Laravel. 206 | 207 | Example: 208 | 209 | ```php 210 | use \Milon\Barcode\DNS1D; 211 | 212 | $d = new DNS1D(); 213 | $d->setStorPath(__DIR__.'/cache/'); 214 | echo $d->getBarcodeHTML('9780691147727', 'EAN13'); 215 | ``` 216 | 217 | ## License 218 | 219 | This package is published under `GNU LGPLv3` license and copyright to [Nuruzzaman Milon](http://milon.im). Original Barcode generation classes were written by Nicola Asuni. The license agreement is on project's root. 220 | 221 | ### [Buy me a coffee ☕](https://paypal.me/tomilon?locale.x=en_US) 222 | 223 | License: GNU LGPLv3
224 | Package Author: [Nuruzzaman Milon](http://milon.im)
225 | Original Barcode Class Author: [Nicola Asuni](http://www.tcpdf.org)
226 | Package Copyright: Nuruzzaman Milon
227 | Barcode Generation Class Copyright:
228 | Nicola Asuni
229 | Tecnick.com LTD
230 | www.tecnick.com 231 | -------------------------------------------------------------------------------- /src/Milon/Barcode/GS1_128/AIData.php: -------------------------------------------------------------------------------- 1 | [18, 18, 'Serial Shipping Container Code (SSCC-18)'], 11 | '01' => [14, 14, 'Global Trade Item Number (GTIN)'], 12 | '02' => [14, 14, 'GTIN of Contained Trade Items'], 13 | '10' => [1, 20, 'Batch or Lot Number'], 14 | '11' => [6, 6, 'Production Date'], 15 | '12' => [6, 6, 'Due Date'], 16 | '13' => [6, 6, 'Packaging Date'], 17 | '15' => [6, 6, 'Best Before Date'], 18 | '16' => [6, 6, 'Sell By Date'], 19 | '17' => [6, 6, 'Expiration Date'], 20 | '20' => [2, 2, 'Internal Product Variant'], 21 | '21' => [1, 20, 'Serial Number'], 22 | '22' => [1, 20, 'Consumer Product Variant'], 23 | '235' => [1, 28, 'Third Party Controlled, Serialised Extension of GTIN (TPX)'], 24 | '240' => [1, 30, 'Additional Item Identification'], 25 | '241' => [1, 30, 'Customer Part Number'], 26 | '242' => [1, 6, 'Made-to-Order Variation Number'], 27 | '243' => [1, 20, 'Packaging Comnponent Number'], 28 | '250' => [1, 30, 'Second Serial Number'], 29 | '251' => [1, 30, 'Reference to Source Entity'], 30 | '253' => [14, 30, 'Global Document Type Identifier (GDTI)'], 31 | '254' => [1, 20, 'GLN Extension Component'], 32 | '255' => [14, 25, 'Global Coupon Number (GCN)'], 33 | '30' => [1, 8, 'Variable Count of Items (variable measure trade item)'], 34 | '310y' => [6, 6, 'Net Weight in kilograms (variable measure trade item)'], 35 | '311y' => [6, 6, 'Length or 1st Dimension, in meters (variable measure trade item)'], 36 | '312y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in meters (variable measure trade item)'], 37 | '313y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in meters (variable measure trade item)'], 38 | '314y' => [6, 6, 'Area, in square meters (variable measure trade item)'], 39 | '315y' => [6, 6, 'Net Volume, in liters (variable measure trade item)'], 40 | '316y' => [6, 6, 'Net Volume, in cubic meters (variable measure trade item)'], 41 | '320y' => [6, 6, 'Net Weight, in pounds (variable measure trade item)'], 42 | '321y' => [6, 6, 'Length or 1st Dimension, in inches (variable measure trade item)'], 43 | '322y' => [6, 6, 'Length or 1st Dimension, in feet (variable measure trade item)'], 44 | '323y' => [6, 6, 'Length, 1st Dimension, in yards (variable measure trade item)'], 45 | '324y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in inches (variable measure trade item)'], 46 | '325y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in feet (variable measure trade item)'], 47 | '326y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in yards (variable measure trade item)'], 48 | '327y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in inches (variable measure trade item)'], 49 | '328y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in feet (variable measure trade item)'], 50 | '329y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in yards (variable measure trade item)'], 51 | '330y' => [6, 6, 'Logistic Weight, in kilograms'], 52 | '331y' => [6, 6, 'Length, or 1st Dimension, in meters'], 53 | '332y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in meters'], 54 | '333y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in meters'], 55 | '334y' => [6, 6, 'Area, in square meters'], 56 | '335y' => [6, 6, 'Logistic Volume, in liters'], 57 | '336y' => [6, 6, 'Logistic Volume, in cubic meters'], 58 | '337y' => [6, 6, 'Kilograms per square meter'], 59 | '340y' => [6, 6, 'Logistic Weight, in pounds'], 60 | '341y' => [6, 6, 'Length or 1st Dimension, in inches'], 61 | '342y' => [6, 6, 'Length or 1st Dimension, in feet'], 62 | '343y' => [6, 6, 'Container Length\/1st Dimension in, in yards'], 63 | '344y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in inches'], 64 | '345y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in feet'], 65 | '346y' => [6, 6, 'Width, Diameter, or 2nd Dimension, in yards'], 66 | '347y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in inches'], 67 | '348y' => [6, 6, 'Depth, Thickness, Height, or 3rd Dimension, in feet'], 68 | '349y' => [6, 6, 'Depth, Thickness, Height, 3rd Dimension, in yards'], 69 | '350y' => [6, 6, 'Area, in square inches (variable measure trade item)'], 70 | '351y' => [6, 6, 'Area, in square feet (variable measure trade item)'], 71 | '352y' => [6, 6, 'Area, in square yards (variable measure trade item)'], 72 | '353y' => [6, 6, 'Area, in square inches'], 73 | '354y' => [6, 6, 'Area, in square feet'], 74 | '355y' => [6, 6, 'Area, in square yards'], 75 | '356y' => [6, 6, 'Net Weight, in troy ounces (variable measure trade item)'], 76 | '357y' => [6, 6, 'Net Weight or volume, in ounces (variable measure trade item)'], 77 | '360y' => [6, 6, 'Net Volume, in quarts (variable measure trade item)'], 78 | '361y' => [6, 6, 'Net Volume, in U.S. gallons (variable measure trade item)'], 79 | '362y' => [6, 6, 'Logistic Volume, in quarts'], 80 | '363y' => [6, 6, 'Logistic Volume, in U.S. gallons'], 81 | '364y' => [6, 6, 'Net Volume, in cubic inches (variable measure trade item)'], 82 | '365y' => [6, 6, 'Net Volume, in cubic feet (variable measure trade item)'], 83 | '366y' => [6, 6, 'Net Volume, in cubic yards (variable measure trade item)'], 84 | '367y' => [6, 6, 'Logistic Volume, in cubic inches'], 85 | '368y' => [6, 6, 'Logistic Volume, in cubic feet'], 86 | '369y' => [6, 6, 'Logistic Volume, in cubic yards'], 87 | '37' => [1, 8, 'Count of trade items'], 88 | '390y' => [1, 15, 'Applicable Amount Payable or Coupon Value, in local currency'], 89 | '391y' => [4, 18, 'Applicable Amount Payable with ISO Currency Code'], 90 | '392y' => [1, 15, 'Applicable Amount Payable, Single Monetary Area (variable measure trade item)'], 91 | '393y' => [4, 18, 'Applicable Amount Payable With ISO Currency Code (variable measure trade item)'], 92 | '394y' => [4, 4, 'Percentage Discount of a Coupon'], 93 | '395y' => [6, 6, 'Amount Payable per unit of measure single monetary area (variable measure trade item)'], 94 | '400' => [1, 30, 'Customer\'s Purchase Order Number'], 95 | '401' => [1, 30, 'Global Identification Number for Consignment (GINC)'], 96 | '402' => [17, 17, 'Global Shipment Identification Number (GSIN)'], 97 | '403' => [1, 30, 'Routing Code'], 98 | '410' => [13, 13, 'Ship To\/Deliver To Global Location Number'], 99 | '411' => [13, 13, 'Bill To\/Invoice To Global Location Number'], 100 | '412' => [13, 13, 'Purchased From Global Location Number'], 101 | '413' => [13, 13, 'Ship For\/Deliver For\/Forward To Global Location Number'], 102 | '414' => [13, 13, 'Identification of a Physical Location - Global Location Number'], 103 | '415' => [13, 13, 'Global Location Number of The Invoicing Party'], 104 | '416' => [13, 13, 'Global Location Number of The Production or Service Location'], 105 | '417' => [13, 13, 'Party GLN'], 106 | '420' => [1, 20, 'Ship To\/Deliver To Postal Code Within a Single Postal Authority'], 107 | '421' => [4, 12, 'Ship To\/Deliver To Postal Code With ISO Country Code'], 108 | '422' => [3, 3, 'Country of Origin of a Trade Item'], 109 | '423' => [3, 15, 'Country of Initial Processing'], 110 | '424' => [3, 3, 'Country of Processing'], 111 | '425' => [3, 3, 'Country of Disassembly'], 112 | '426' => [3, 3, 'Country Covering Full Process Chain'], 113 | '427' => [1, 3, 'Country Subdivision of Origin'], 114 | '4300' => [1, 35, 'Ship-to \/ Deliver-to company name'], 115 | '4301' => [1, 35, 'Ship-to \/ Deliver-to contact'], 116 | '4302' => [1, 70, 'Ship-to \/ Deliver-to address line 1'], 117 | '4303' => [1, 70, 'Ship-to \/ Deliver-to address line 2'], 118 | '4304' => [1, 70, 'Ship-to \/ Deliver-to suburb'], 119 | '4305' => [1, 70, 'Ship-to \/ Deliver-to locality'], 120 | '4306' => [1, 70, 'Ship-to \/ Deliver-to region'], 121 | '4307' => [2, 2, 'Ship-to \/ Deliver-to country code'], 122 | '4308' => [1, 30, 'Ship-to \/ Deliver-to telephone number'], 123 | '4310' => [1, 35, 'Return-to company name'], 124 | '4311' => [1, 35, 'Return-to contact'], 125 | '4312' => [1, 70, 'Return-to address line 1'], 126 | '4313' => [1, 70, 'Return-to address line 2'], 127 | '4314' => [1, 70, 'Return-to suburb'], 128 | '4315' => [1, 70, 'Return-to locality'], 129 | '4316' => [1, 70, 'Return-to region'], 130 | '4317' => [2, 2, 'Return-to country code'], 131 | '4318' => [1, 20, 'Return-to postal code'], 132 | '4319' => [1, 30, 'Return-to telephone number'], 133 | '4320' => [1, 35, 'Service code description'], 134 | '4321' => [1, 1, 'Dangerous goods flag'], 135 | '4322' => [1, 1, 'Authority to leave'], 136 | '4323' => [1, 1, 'Signature required flag'], 137 | '4324' => [10, 10, 'Not before delivery date time'], 138 | '4325' => [10, 10, 'Not after delivery date time'], 139 | '4326' => [6, 6, 'Release date'], 140 | '7001' => [13, 13, 'NATO Stock Number (NSN)'], 141 | '7002' => [1, 30, 'UN\/ECE Meat Carcasses and Cuts Classification'], 142 | '7003' => [10, 10, 'Expiration Date and Time'], 143 | '7004' => [1, 4, 'Active Potency'], 144 | '7005' => [1, 12, 'Catch Area'], 145 | '7006' => [6, 6, 'First Freeze Date'], 146 | '7007' => [6, 12, 'Harvest Date'], 147 | '7008' => [1, 3, 'Species For Fishery Purposes'], 148 | '7009' => [1, 10, 'Fishing Gear Type'], 149 | '7010' => [1, 2, 'Production Method'], 150 | '7020' => [1, 20, 'Refurbishment Lot ID'], 151 | '7021' => [1, 20, 'Functional Status'], 152 | '7022' => [1, 20, 'Revision Status'], 153 | '7023' => [1, 30, 'Global Individual Asset Identifier (GIAI) of an Assembly'], 154 | '703y' => [3, 30, 'Number of Processor with ISO Country Code'], 155 | '7040' => [4, 4, 'GS1 UIC with Extension 1 and Importer index'], 156 | '710' => [1, 20, 'National Healthcare Reimbursement Number (NHRN) - Germany PZN'], 157 | '711' => [1, 20, 'National Healthcare Reimbursement Number (NHRN) - France CIP'], 158 | '712' => [1, 20, 'National Healthcare Reimbursement Number (NHRN) - Spain CN'], 159 | '713' => [1, 20, 'National Healthcare Reimbursement Number (NHRN) - Brasil DRN'], 160 | '714' => [1, 20, 'National Healthcare Reimbursement Number (NHRN) - Portugal AIM'], 161 | '723y' => [2, 30, 'Certification reference'], 162 | '7240' => [1, 20, 'Protocol ID'], 163 | '8001' => [14, 14, 'Roll Products - Width\/Length\/Core Diameter\/Direction\/Splices'], 164 | '8002' => [1, 20, 'Cellular Mobile Telphone Identifier'], 165 | '8003' => [15, 30, 'Global Returnable Asset Identifier (GRAI)'], 166 | '8004' => [1, 30, 'Global Individual Asset Identifier (GIAI)'], 167 | '8005' => [6, 6, 'Price per Unit of Measure'], 168 | '8006' => [18, 18, 'Identification of an Individual Trade Item Piece'], 169 | '8007' => [1, 34, 'International Bank Account Number (IBAN)'], 170 | '8008' => [8, 12, 'Date and Time of Production'], 171 | '8009' => [1, 50, 'Optically Readable Sensor Indicator'], 172 | '8010' => [1, 30, 'Component\/Part Identifier (CPID)'], 173 | '8011' => [1, 12, 'Component\/Part Identifier Serial Number (CPID Serial)'], 174 | '8012' => [1, 20, 'Software Version'], 175 | '8013' => [1, 30, 'Global Model Number (GMN)'], 176 | '8017' => [18, 18, 'Global Service Relation Number to Identify the Relationship Between an Organisation Offering Services and the Provider of Services'], 177 | '8018' => [18, 18, 'Global Service Relation Number to Identify the Relationship Between an Organisation Offering Services and the Recipient of Services'], 178 | '8019' => [1, 10, 'Service Relation Instance Number (SRIN)'], 179 | '8020' => [1, 25, 'Payment Slip Reference Number'], 180 | '8026' => [18, 18, 'Identification of pieces of a trade item (ITIP) contained in a logistic unit'], 181 | '8110' => [1, 70, 'Coupon Code Identification for Use in North America'], 182 | '8111' => [4, 4, 'Loyalty Points of a Coupon'], 183 | '8112' => [1, 70, 'Paperless Coupon Code Identification for Use in North America (AI 8112)'], 184 | '8200' => [1, 70, 'Extended Packaging URL'], 185 | '90' => [1, 30, 'Information Mutually Agreed Between Trading Partners'], 186 | '91' => [1, 90, 'Internal Company Codes'], 187 | '92' => [1, 90, 'Internal Company Codes'], 188 | '93' => [1, 90, 'Internal Company Codes'], 189 | '94' => [1, 90, 'Internal Company Codes'], 190 | '95' => [1, 90, 'Internal Company Codes'], 191 | '96' => [1, 90, 'Internal Company Codes'], 192 | '97' => [1, 90, 'Internal Company Codes'], 193 | '98' => [1, 90, 'Internal Company Codes'], 194 | '99' => [1, 90, 'Internal Company Codes'] 195 | ]; 196 | } 197 | -------------------------------------------------------------------------------- /src/Milon/Barcode/DNS2D.php: -------------------------------------------------------------------------------- 1 | . 29 | // 30 | // See LICENSE.TXT file for more information. 31 | // ------------------------------------------------------------------- 32 | // 33 | // Description : PHP class to creates array representations for 34 | // 2D barcodes to be used with TCPDF. 35 | // 36 | //============================================================+ 37 | /** 38 | * @file 39 | * PHP class to creates array representations for 2D barcodes to be used with TCPDF. 40 | * @package com.tecnick.tcpdf 41 | * @author Nicola Asuni 42 | * @version 1.0.015 43 | */ 44 | /** 45 | * @class TCPDF2DBarcode 46 | * PHP class to creates array representations for 2D barcodes to be used with TCPDF (http://www.tcpdf.org). 47 | * @package com.tecnick.tcpdf 48 | * @version 1.0.015 49 | * @author Nicola Asuni 50 | */ 51 | 52 | use Milon\Barcode\QRcode; 53 | use Milon\Barcode\Datamatrix; 54 | use Milon\Barcode\PDF417; 55 | use Illuminate\Support\Str; 56 | 57 | /* 58 | * To change this template, choose Tools | Templates 59 | * and open the template in the editor. 60 | */ 61 | 62 | /** 63 | * Description of DNS2D 64 | * 65 | * @author dinesh 66 | */ 67 | class DNS2D { 68 | 69 | /** 70 | * Array representation of barcode. 71 | * @protected 72 | */ 73 | protected $barcode_array = false; 74 | 75 | /** 76 | * path to save png in getBarcodePNGPath 77 | * @var 78 | */ 79 | protected $store_path; 80 | 81 | /** 82 | * Return a SVG string representation of barcode. 83 | *
  • $arrcode['code'] code to be printed on text label
  • 84 | *
  • $arrcode['num_rows'] required number of rows
  • 85 | *
  • $arrcode['num_cols'] required number of columns
  • 86 | *
  • $arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)
  • 87 | * @param $code (string) code to print 88 | * @param $type (string) type of barcode: 89 | * @param $w (int) Width of a single rectangle element in user units. 90 | * @param $h (int) Height of a single rectangle element in user units. 91 | * @param $color (string) Foreground color (in SVG format) for bar elements (background is transparent). 92 | * @return string SVG code. 93 | * @protected 94 | */ 95 | public function getBarcodeSVG($code, $type, $w = 3, $h = 3, $color = 'black') { 96 | if (!$this->store_path) { 97 | $this->setStorPath(app('config')->get("barcode.store_path")); 98 | } 99 | //set barcode code and type 100 | $this->setBarcode($code, $type); 101 | // replace table for special characters 102 | $repstr = array("\0" => '', '&' => '&', '<' => '<', '>' => '>'); 103 | $svg = '<' . '?' . 'xml version="1.0" standalone="no"' . '?' . '>' . "\n"; 104 | $svg .= '' . "\n"; 105 | $svg .= '' . "\n"; 106 | $svg .= "\t" . '' . "\n"; 107 | // print barcode elements 108 | $y = 0; 109 | // for each row 110 | for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { 111 | $x = 0; 112 | // for each column 113 | for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { 114 | if ($this->barcode_array['bcode'][$r][$c] == 1) { 115 | // draw a single barcode cell 116 | $svg .= "\t\t" . '' . "\n"; 117 | } 118 | $x += $w; 119 | } 120 | $y += $h; 121 | } 122 | $svg .= "\t" . '' . "\n"; 123 | $svg .= '' . "\n"; 124 | return $svg; 125 | } 126 | 127 | /** 128 | * Return an HTML representation of barcode. 129 | *
  • $arrcode['code'] code to be printed on text label
  • 130 | *
  • $arrcode['num_rows'] required number of rows
  • 131 | *
  • $arrcode['num_cols'] required number of columns
  • 132 | *
  • $arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)
  • 133 | * @param $code (string) code to print 134 | * @param $type (string) type of barcode: 135 | * @param $w (int) Width of a single rectangle element in pixels. 136 | * @param $h (int) Height of a single rectangle element in pixels. 137 | * @param $color (string) Foreground color for bar elements (background is transparent). 138 | * @return string HTML code. 139 | * @protected 140 | */ 141 | public function getBarcodeHTML($code, $type, $w = 10, $h = 10, $color = 'black') { 142 | if (!$this->store_path) { 143 | $this->setStorPath(app('config')->get("barcode.store_path")); 144 | } 145 | //set barcode code and type 146 | $this->setBarcode($code, $type); 147 | $html = '
    ' . "\n"; 148 | // print barcode elements 149 | $y = 0; 150 | // for each row 151 | for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { 152 | $x = 0; 153 | // for each column 154 | for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { 155 | if ($this->barcode_array['bcode'][$r][$c] == 1) { 156 | // draw a single barcode cell 157 | $html .= '
     
    ' . "\n"; 158 | } 159 | $x += $w; 160 | } 161 | $y += $h; 162 | } 163 | $html .= '
    ' . "\n"; 164 | return $html; 165 | } 166 | 167 | /** 168 | * Return a PNG image representation of barcode (requires GD or Imagick library). 169 | *
  • $arrcode['code'] code to be printed on text label
  • 170 | *
  • $arrcode['num_rows'] required number of rows
  • 171 | *
  • $arrcode['num_cols'] required number of columns
  • 172 | *
  • $arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)
  • 173 | * @param $code (string) code to print 174 | * @param $type (string) type of barcode: 175 | * @param $w (int) Width of a single rectangle element in pixels. 176 | * @param $h (int) Height of a single rectangle element in pixels. 177 | * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). 178 | * @return string|false path or false in case of error. 179 | * @protected 180 | */ 181 | public function getBarcodePNG($code, $type, $w = 3, $h = 3, $color = array(0, 0, 0)) { 182 | if (!$this->store_path) { 183 | $this->setStorPath(app('config')->get("barcode.store_path")); 184 | } 185 | //set barcode code and type 186 | $this->setBarcode($code, $type); 187 | // calculate image size 188 | $width = ($this->barcode_array['num_cols'] * $w); 189 | $height = ($this->barcode_array['num_rows'] * $h); 190 | if (function_exists('imagecreate')) { 191 | // GD library 192 | $imagick = false; 193 | $png = imagecreate($width, $height); 194 | $bgcol = imagecolorallocate($png, 255, 255, 255); 195 | imagecolortransparent($png, $bgcol); 196 | $fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]); 197 | } elseif (extension_loaded('imagick')) { 198 | $imagick = true; 199 | $bgcol = new \imagickpixel('rgb(255,255,255'); 200 | $fgcol = new \imagickpixel('rgb(' . $color[0] . ',' . $color[1] . ',' . $color[2] . ')'); 201 | $png = new \Imagick(); 202 | $png->newImage($width, $height, 'none', 'png'); 203 | $bar = new \imagickdraw(); 204 | $bar->setfillcolor($fgcol); 205 | } else { 206 | return false; 207 | } 208 | // print barcode elements 209 | $y = 0; 210 | // for each row 211 | for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { 212 | $x = 0; 213 | // for each column 214 | for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { 215 | if ($this->barcode_array['bcode'][$r][$c] == 1) { 216 | // draw a single barcode cell 217 | if ($imagick) { 218 | $bar->rectangle($x, $y, ($x + ($w-1)), ($y + ($h-1))); 219 | } else { 220 | imagefilledrectangle($png, $x, $y, ($x + ($w-1)), ($y + ($h-1)), $fgcol); 221 | } 222 | } 223 | $x += $w; 224 | } 225 | $y += $h; 226 | } 227 | ob_start(); 228 | // get image out put 229 | 230 | if ($imagick) { 231 | $png->drawimage($bar); 232 | echo $png; 233 | } else { 234 | imagepng($png); 235 | imagedestroy($png); 236 | } 237 | $image = ob_get_clean(); 238 | $image = base64_encode($image); 239 | //$image = 'data:image/png;base64,' . base64_encode($image); 240 | return $image; 241 | } 242 | 243 | /** 244 | * Return a .png file path which create in server 245 | * @param $code (string) code to print 246 | * @param $type (string) type of barcode: 247 | * @param $w (int) Width of a single bar element in pixels. 248 | * @param $h (int) Height of a single bar element in pixels. 249 | * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). 250 | * @return string|false url or false in case of error. 251 | * @protected 252 | */ 253 | protected function getBarcodePNGUri($code, $type, $w = 3, $h = 3, $color = array(0, 0, 0)) { 254 | $path = $this->getBarcodePNGPath($code, $type, $w, $h, $color); 255 | // Replace backslash (Windows) with forward slashes, to make it compatible with url(). 256 | return url(str_replace('\\', '/', $path)); 257 | } 258 | 259 | /** 260 | * Return a .png file path which create in server 261 | *
  • $arrcode['code'] code to be printed on text label
  • 262 | *
  • $arrcode['num_rows'] required number of rows
  • 263 | *
  • $arrcode['num_cols'] required number of columns
  • 264 | *
  • $arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)
  • 265 | * @param $code (string) code to print 266 | * @param $type (string) type of barcode: 267 | * @param $w (int) Width of a single rectangle element in pixels. 268 | * @param $h (int) Height of a single rectangle element in pixels. 269 | * @param $color (array) RGB (0-255) foreground color for bar elements (background is transparent). 270 | * @return string|false path of image which was created or false in case of error 271 | * @protected 272 | */ 273 | protected function getBarcodePNGPath($code, $type, $w = 3, $h = 3, $color = array(0, 0, 0)) { 274 | if (!$this->store_path) { 275 | $this->setStorPath(app('config')->get("barcode.store_path")); 276 | } 277 | //set barcode code and type 278 | $this->setBarcode($code, $type); 279 | // calculate image size 280 | $width = ($this->barcode_array['num_cols'] * $w); 281 | $height = ($this->barcode_array['num_rows'] * $h); 282 | if (function_exists('imagecreate')) { 283 | // GD library 284 | $imagick = false; 285 | $png = imagecreate($width, $height); 286 | $bgcol = imagecolorallocate($png, 255, 255, 255); 287 | imagecolortransparent($png, $bgcol); 288 | $fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]); 289 | } elseif (extension_loaded('imagick')) { 290 | $imagick = true; 291 | $bgcol = new imagickpixel('rgb(255,255,255'); 292 | $fgcol = new imagickpixel('rgb(' . $color[0] . ',' . $color[1] . ',' . $color[2] . ')'); 293 | $png = new Imagick(); 294 | $png->newImage($width, $height, 'none', 'png'); 295 | $bar = new imagickdraw(); 296 | $bar->setfillcolor($fgcol); 297 | } else { 298 | return false; 299 | } 300 | // print barcode elements 301 | $y = 0; 302 | // for each row 303 | for ($r = 0; $r < $this->barcode_array['num_rows']; ++$r) { 304 | $x = 0; 305 | // for each column 306 | for ($c = 0; $c < $this->barcode_array['num_cols']; ++$c) { 307 | if ($this->barcode_array['bcode'][$r][$c] == 1) { 308 | // draw a single barcode cell 309 | if ($imagick) { 310 | $bar->rectangle($x, $y, ($x + $w), ($y + $h)); 311 | } else { 312 | imagefilledrectangle($png, $x, $y, ($x + $w), ($y + $h), $fgcol); 313 | } 314 | } 315 | $x += $w; 316 | } 317 | $y += $h; 318 | } 319 | $file_name= Str::slug($code.$type); 320 | $save_file = $this->checkfile($this->store_path . $file_name . ".png"); 321 | 322 | if ($imagick) { 323 | $png->drawimage($bar); 324 | //echo $png; 325 | } 326 | if (ImagePng($png, $save_file)) { 327 | imagedestroy($png); 328 | return str_replace(public_path(), '', $save_file); 329 | } else { 330 | imagedestroy($png); 331 | return $code; 332 | } 333 | } 334 | 335 | /** 336 | * Set the barcode. 337 | * @param $code (string) code to print 338 | * @param $type (string) type of barcode: 339 | * @return array 340 | */ 341 | protected function setBarcode($code, $type) { 342 | $mode = explode(',', $type); 343 | $qrtype = strtoupper($mode[0]); 344 | switch ($qrtype) { 345 | case 'DATAMATRIX': { // DATAMATRIX (ISO/IEC 16022) 346 | $barcode = new Datamatrix($code); 347 | $this->barcode_array = $barcode->getBarcodeArray(); 348 | $this->barcode_array['code'] = $code; 349 | break; 350 | } 351 | case 'PDF417': { // PDF417 (ISO/IEC 15438:2006) 352 | if (!isset($mode[1]) OR ($mode[1] === '')) { 353 | $aspectratio = 2; // default aspect ratio (width / height) 354 | } else { 355 | $aspectratio = floatval($mode[1]); 356 | } 357 | if (!isset($mode[2]) OR ($mode[2] === '')) { 358 | $ecl = -1; // default error correction level (auto) 359 | } else { 360 | $ecl = intval($mode[2]); 361 | } 362 | // set macro block 363 | $macro = array(); 364 | if (isset($mode[3]) AND ($mode[3] !== '') AND isset($mode[4]) AND ($mode[4] !== '') AND isset($mode[5]) AND ($mode[5] !== '')) { 365 | $macro['segment_total'] = intval($mode[3]); 366 | $macro['segment_index'] = intval($mode[4]); 367 | $macro['file_id'] = strtr($mode[5], "\xff", ','); 368 | for ($i = 0; $i < 7; ++$i) { 369 | $o = $i + 6; 370 | if (isset($mode[$o]) AND ($mode[$o] !== '')) { 371 | // add option 372 | $macro['option_' . $i] = strtr($mode[$o], "\xff", ','); 373 | } 374 | } 375 | } 376 | $barcode = new PDF417($code, $ecl, $aspectratio, $macro); 377 | $this->barcode_array = $barcode->getBarcodeArray(); 378 | $this->barcode_array['code'] = $code; 379 | break; 380 | } 381 | case 'QRCODE': { // QR-CODE 382 | if (!isset($mode[1]) OR (!in_array($mode[1], array('L', 'M', 'Q', 'H')))) { 383 | $mode[1] = 'L'; // Ddefault: Low error correction 384 | } 385 | $barcode = new QRcode($code, strtoupper($mode[1])); 386 | $this->barcode_array = $barcode->getBarcodeArray(); 387 | $this->barcode_array['code'] = $code; 388 | break; 389 | } 390 | default: { 391 | $this->barcode_array = false; 392 | } 393 | } 394 | } 395 | 396 | /** 397 | * 398 | * @param type $path 399 | * @return type 400 | */ 401 | protected function checkfile($path) { 402 | if (file_exists($path)) { 403 | unlink($path); 404 | } 405 | return $path; 406 | } 407 | 408 | public function setStorPath($path) { 409 | $this->store_path = rtrim((string) $path, '/' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; 410 | return $this; 411 | } 412 | 413 | 414 | 415 | /** 416 | * Handle dynamic method calls. 417 | * 418 | * @param string $method 419 | * @param array $parameters 420 | * @return mixed 421 | */ 422 | public function __call($method, $parameters) 423 | { 424 | return $this->$method(...$parameters); 425 | } 426 | 427 | /** 428 | * Handle dynamic static method calls. 429 | * 430 | * @param string $method 431 | * @param array $parameters 432 | * @return mixed 433 | */ 434 | public static function __callStatic($method, $parameters) 435 | { 436 | return (new static)->$method(...$parameters); 437 | } 438 | } 439 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | ********************************************************************** 2 | * TCPDF LICENSE 3 | ********************************************************************** 4 | 5 | TCPDF is free software: you can redistribute it and/or modify it 6 | under the terms of the GNU Lesser General Public License as 7 | published by the Free Software Foundation, either version 3 of the 8 | License, or (at your option) any later version. 9 | 10 | ********************************************************************** 11 | ********************************************************************** 12 | 13 | GNU LESSER GENERAL PUBLIC LICENSE 14 | Version 3, 29 June 2007 15 | 16 | Copyright (C) 2007 Free Software Foundation, Inc. 17 | Everyone is permitted to copy and distribute verbatim copies 18 | of this license document, but changing it is not allowed. 19 | 20 | 21 | This version of the GNU Lesser General Public License incorporates 22 | the terms and conditions of version 3 of the GNU General Public 23 | License, supplemented by the additional permissions listed below. 24 | 25 | 0. Additional Definitions. 26 | 27 | As used herein, "this License" refers to version 3 of the GNU Lesser 28 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 29 | General Public License. 30 | 31 | "The Library" refers to a covered work governed by this License, 32 | other than an Application or a Combined Work as defined below. 33 | 34 | An "Application" is any work that makes use of an interface provided 35 | by the Library, but which is not otherwise based on the Library. 36 | Defining a subclass of a class defined by the Library is deemed a mode 37 | of using an interface provided by the Library. 38 | 39 | A "Combined Work" is a work produced by combining or linking an 40 | Application with the Library. The particular version of the Library 41 | with which the Combined Work was made is also called the "Linked 42 | Version". 43 | 44 | The "Minimal Corresponding Source" for a Combined Work means the 45 | Corresponding Source for the Combined Work, excluding any source code 46 | for portions of the Combined Work that, considered in isolation, are 47 | based on the Application, and not on the Linked Version. 48 | 49 | The "Corresponding Application Code" for a Combined Work means the 50 | object code and/or source code for the Application, including any data 51 | and utility programs needed for reproducing the Combined Work from the 52 | Application, but excluding the System Libraries of the Combined Work. 53 | 54 | 1. Exception to Section 3 of the GNU GPL. 55 | 56 | You may convey a covered work under sections 3 and 4 of this License 57 | without being bound by section 3 of the GNU GPL. 58 | 59 | 2. Conveying Modified Versions. 60 | 61 | If you modify a copy of the Library, and, in your modifications, a 62 | facility refers to a function or data to be supplied by an Application 63 | that uses the facility (other than as an argument passed when the 64 | facility is invoked), then you may convey a copy of the modified 65 | version: 66 | 67 | a) under this License, provided that you make a good faith effort to 68 | ensure that, in the event an Application does not supply the 69 | function or data, the facility still operates, and performs 70 | whatever part of its purpose remains meaningful, or 71 | 72 | b) under the GNU GPL, with none of the additional permissions of 73 | this License applicable to that copy. 74 | 75 | 3. Object Code Incorporating Material from Library Header Files. 76 | 77 | The object code form of an Application may incorporate material from 78 | a header file that is part of the Library. You may convey such object 79 | code under terms of your choice, provided that, if the incorporated 80 | material is not limited to numerical parameters, data structure 81 | layouts and accessors, or small macros, inline functions and templates 82 | (ten or fewer lines in length), you do both of the following: 83 | 84 | a) Give prominent notice with each copy of the object code that the 85 | Library is used in it and that the Library and its use are 86 | covered by this License. 87 | 88 | b) Accompany the object code with a copy of the GNU GPL and this license 89 | document. 90 | 91 | 4. Combined Works. 92 | 93 | You may convey a Combined Work under terms of your choice that, 94 | taken together, effectively do not restrict modification of the 95 | portions of the Library contained in the Combined Work and reverse 96 | engineering for debugging such modifications, if you also do each of 97 | the following: 98 | 99 | a) Give prominent notice with each copy of the Combined Work that 100 | the Library is used in it and that the Library and its use are 101 | covered by this License. 102 | 103 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 104 | document. 105 | 106 | c) For a Combined Work that displays copyright notices during 107 | execution, include the copyright notice for the Library among 108 | these notices, as well as a reference directing the user to the 109 | copies of the GNU GPL and this license document. 110 | 111 | d) Do one of the following: 112 | 113 | 0) Convey the Minimal Corresponding Source under the terms of this 114 | License, and the Corresponding Application Code in a form 115 | suitable for, and under terms that permit, the user to 116 | recombine or relink the Application with a modified version of 117 | the Linked Version to produce a modified Combined Work, in the 118 | manner specified by section 6 of the GNU GPL for conveying 119 | Corresponding Source. 120 | 121 | 1) Use a suitable shared library mechanism for linking with the 122 | Library. A suitable mechanism is one that (a) uses at run time 123 | a copy of the Library already present on the user's computer 124 | system, and (b) will operate properly with a modified version 125 | of the Library that is interface-compatible with the Linked 126 | Version. 127 | 128 | e) Provide Installation Information, but only if you would otherwise 129 | be required to provide such information under section 6 of the 130 | GNU GPL, and only to the extent that such information is 131 | necessary to install and execute a modified version of the 132 | Combined Work produced by recombining or relinking the 133 | Application with a modified version of the Linked Version. (If 134 | you use option 4d0, the Installation Information must accompany 135 | the Minimal Corresponding Source and Corresponding Application 136 | Code. If you use option 4d1, you must provide the Installation 137 | Information in the manner specified by section 6 of the GNU GPL 138 | for conveying Corresponding Source.) 139 | 140 | 5. Combined Libraries. 141 | 142 | You may place library facilities that are a work based on the 143 | Library side by side in a single library together with other library 144 | facilities that are not Applications and are not covered by this 145 | License, and convey such a combined library under terms of your 146 | choice, if you do both of the following: 147 | 148 | a) Accompany the combined library with a copy of the same work based 149 | on the Library, uncombined with any other library facilities, 150 | conveyed under the terms of this License. 151 | 152 | b) Give prominent notice with the combined library that part of it 153 | is a work based on the Library, and explaining where to find the 154 | accompanying uncombined form of the same work. 155 | 156 | 6. Revised Versions of the GNU Lesser General Public License. 157 | 158 | The Free Software Foundation may publish revised and/or new versions 159 | of the GNU Lesser General Public License from time to time. Such new 160 | versions will be similar in spirit to the present version, but may 161 | differ in detail to address new problems or concerns. 162 | 163 | Each version is given a distinguishing version number. If the 164 | Library as you received it specifies that a certain numbered version 165 | of the GNU Lesser General Public License "or any later version" 166 | applies to it, you have the option of following the terms and 167 | conditions either of that published version or of any later version 168 | published by the Free Software Foundation. If the Library as you 169 | received it does not specify a version number of the GNU Lesser 170 | General Public License, you may choose any version of the GNU Lesser 171 | General Public License ever published by the Free Software Foundation. 172 | 173 | If the Library as you received it specifies that a proxy can decide 174 | whether future versions of the GNU Lesser General Public License shall 175 | apply, that proxy's public statement of acceptance of any version is 176 | permanent authorization for you to choose that version for the 177 | Library. 178 | 179 | ********************************************************************** 180 | ********************************************************************** 181 | 182 | GNU GENERAL PUBLIC LICENSE 183 | Version 3, 29 June 2007 184 | 185 | Copyright (C) 2007 Free Software Foundation, Inc. 186 | Everyone is permitted to copy and distribute verbatim copies 187 | of this license document, but changing it is not allowed. 188 | 189 | Preamble 190 | 191 | The GNU General Public License is a free, copyleft license for 192 | software and other kinds of works. 193 | 194 | The licenses for most software and other practical works are designed 195 | to take away your freedom to share and change the works. By contrast, 196 | the GNU General Public License is intended to guarantee your freedom to 197 | share and change all versions of a program--to make sure it remains free 198 | software for all its users. We, the Free Software Foundation, use the 199 | GNU General Public License for most of our software; it applies also to 200 | any other work released this way by its authors. You can apply it to 201 | your programs, too. 202 | 203 | When we speak of free software, we are referring to freedom, not 204 | price. Our General Public Licenses are designed to make sure that you 205 | have the freedom to distribute copies of free software (and charge for 206 | them if you wish), that you receive source code or can get it if you 207 | want it, that you can change the software or use pieces of it in new 208 | free programs, and that you know you can do these things. 209 | 210 | To protect your rights, we need to prevent others from denying you 211 | these rights or asking you to surrender the rights. Therefore, you have 212 | certain responsibilities if you distribute copies of the software, or if 213 | you modify it: responsibilities to respect the freedom of others. 214 | 215 | For example, if you distribute copies of such a program, whether 216 | gratis or for a fee, you must pass on to the recipients the same 217 | freedoms that you received. You must make sure that they, too, receive 218 | or can get the source code. And you must show them these terms so they 219 | know their rights. 220 | 221 | Developers that use the GNU GPL protect your rights with two steps: 222 | (1) assert copyright on the software, and (2) offer you this License 223 | giving you legal permission to copy, distribute and/or modify it. 224 | 225 | For the developers' and authors' protection, the GPL clearly explains 226 | that there is no warranty for this free software. For both users' and 227 | authors' sake, the GPL requires that modified versions be marked as 228 | changed, so that their problems will not be attributed erroneously to 229 | authors of previous versions. 230 | 231 | Some devices are designed to deny users access to install or run 232 | modified versions of the software inside them, although the manufacturer 233 | can do so. This is fundamentally incompatible with the aim of 234 | protecting users' freedom to change the software. The systematic 235 | pattern of such abuse occurs in the area of products for individuals to 236 | use, which is precisely where it is most unacceptable. Therefore, we 237 | have designed this version of the GPL to prohibit the practice for those 238 | products. If such problems arise substantially in other domains, we 239 | stand ready to extend this provision to those domains in future versions 240 | of the GPL, as needed to protect the freedom of users. 241 | 242 | Finally, every program is threatened constantly by software patents. 243 | States should not allow patents to restrict development and use of 244 | software on general-purpose computers, but in those that do, we wish to 245 | avoid the special danger that patents applied to a free program could 246 | make it effectively proprietary. To prevent this, the GPL assures that 247 | patents cannot be used to render the program non-free. 248 | 249 | The precise terms and conditions for copying, distribution and 250 | modification follow. 251 | 252 | TERMS AND CONDITIONS 253 | 254 | 0. Definitions. 255 | 256 | "This License" refers to version 3 of the GNU General Public License. 257 | 258 | "Copyright" also means copyright-like laws that apply to other kinds of 259 | works, such as semiconductor masks. 260 | 261 | "The Program" refers to any copyrightable work licensed under this 262 | License. Each licensee is addressed as "you". "Licensees" and 263 | "recipients" may be individuals or organizations. 264 | 265 | To "modify" a work means to copy from or adapt all or part of the work 266 | in a fashion requiring copyright permission, other than the making of an 267 | exact copy. The resulting work is called a "modified version" of the 268 | earlier work or a work "based on" the earlier work. 269 | 270 | A "covered work" means either the unmodified Program or a work based 271 | on the Program. 272 | 273 | To "propagate" a work means to do anything with it that, without 274 | permission, would make you directly or secondarily liable for 275 | infringement under applicable copyright law, except executing it on a 276 | computer or modifying a private copy. Propagation includes copying, 277 | distribution (with or without modification), making available to the 278 | public, and in some countries other activities as well. 279 | 280 | To "convey" a work means any kind of propagation that enables other 281 | parties to make or receive copies. Mere interaction with a user through 282 | a computer network, with no transfer of a copy, is not conveying. 283 | 284 | An interactive user interface displays "Appropriate Legal Notices" 285 | to the extent that it includes a convenient and prominently visible 286 | feature that (1) displays an appropriate copyright notice, and (2) 287 | tells the user that there is no warranty for the work (except to the 288 | extent that warranties are provided), that licensees may convey the 289 | work under this License, and how to view a copy of this License. If 290 | the interface presents a list of user commands or options, such as a 291 | menu, a prominent item in the list meets this criterion. 292 | 293 | 1. Source Code. 294 | 295 | The "source code" for a work means the preferred form of the work 296 | for making modifications to it. "Object code" means any non-source 297 | form of a work. 298 | 299 | A "Standard Interface" means an interface that either is an official 300 | standard defined by a recognized standards body, or, in the case of 301 | interfaces specified for a particular programming language, one that 302 | is widely used among developers working in that language. 303 | 304 | The "System Libraries" of an executable work include anything, other 305 | than the work as a whole, that (a) is included in the normal form of 306 | packaging a Major Component, but which is not part of that Major 307 | Component, and (b) serves only to enable use of the work with that 308 | Major Component, or to implement a Standard Interface for which an 309 | implementation is available to the public in source code form. A 310 | "Major Component", in this context, means a major essential component 311 | (kernel, window system, and so on) of the specific operating system 312 | (if any) on which the executable work runs, or a compiler used to 313 | produce the work, or an object code interpreter used to run it. 314 | 315 | The "Corresponding Source" for a work in object code form means all 316 | the source code needed to generate, install, and (for an executable 317 | work) run the object code and to modify the work, including scripts to 318 | control those activities. However, it does not include the work's 319 | System Libraries, or general-purpose tools or generally available free 320 | programs which are used unmodified in performing those activities but 321 | which are not part of the work. For example, Corresponding Source 322 | includes interface definition files associated with source files for 323 | the work, and the source code for shared libraries and dynamically 324 | linked subprograms that the work is specifically designed to require, 325 | such as by intimate data communication or control flow between those 326 | subprograms and other parts of the work. 327 | 328 | The Corresponding Source need not include anything that users 329 | can regenerate automatically from other parts of the Corresponding 330 | Source. 331 | 332 | The Corresponding Source for a work in source code form is that 333 | same work. 334 | 335 | 2. Basic Permissions. 336 | 337 | All rights granted under this License are granted for the term of 338 | copyright on the Program, and are irrevocable provided the stated 339 | conditions are met. This License explicitly affirms your unlimited 340 | permission to run the unmodified Program. The output from running a 341 | covered work is covered by this License only if the output, given its 342 | content, constitutes a covered work. This License acknowledges your 343 | rights of fair use or other equivalent, as provided by copyright law. 344 | 345 | You may make, run and propagate covered works that you do not 346 | convey, without conditions so long as your license otherwise remains 347 | in force. You may convey covered works to others for the sole purpose 348 | of having them make modifications exclusively for you, or provide you 349 | with facilities for running those works, provided that you comply with 350 | the terms of this License in conveying all material for which you do 351 | not control copyright. Those thus making or running the covered works 352 | for you must do so exclusively on your behalf, under your direction 353 | and control, on terms that prohibit them from making any copies of 354 | your copyrighted material outside their relationship with you. 355 | 356 | Conveying under any other circumstances is permitted solely under 357 | the conditions stated below. Sublicensing is not allowed; section 10 358 | makes it unnecessary. 359 | 360 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 361 | 362 | No covered work shall be deemed part of an effective technological 363 | measure under any applicable law fulfilling obligations under article 364 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 365 | similar laws prohibiting or restricting circumvention of such 366 | measures. 367 | 368 | When you convey a covered work, you waive any legal power to forbid 369 | circumvention of technological measures to the extent such circumvention 370 | is effected by exercising rights under this License with respect to 371 | the covered work, and you disclaim any intention to limit operation or 372 | modification of the work as a means of enforcing, against the work's 373 | users, your or third parties' legal rights to forbid circumvention of 374 | technological measures. 375 | 376 | 4. Conveying Verbatim Copies. 377 | 378 | You may convey verbatim copies of the Program's source code as you 379 | receive it, in any medium, provided that you conspicuously and 380 | appropriately publish on each copy an appropriate copyright notice; 381 | keep intact all notices stating that this License and any 382 | non-permissive terms added in accord with section 7 apply to the code; 383 | keep intact all notices of the absence of any warranty; and give all 384 | recipients a copy of this License along with the Program. 385 | 386 | You may charge any price or no price for each copy that you convey, 387 | and you may offer support or warranty protection for a fee. 388 | 389 | 5. Conveying Modified Source Versions. 390 | 391 | You may convey a work based on the Program, or the modifications to 392 | produce it from the Program, in the form of source code under the 393 | terms of section 4, provided that you also meet all of these conditions: 394 | 395 | a) The work must carry prominent notices stating that you modified 396 | it, and giving a relevant date. 397 | 398 | b) The work must carry prominent notices stating that it is 399 | released under this License and any conditions added under section 400 | 7. This requirement modifies the requirement in section 4 to 401 | "keep intact all notices". 402 | 403 | c) You must license the entire work, as a whole, under this 404 | License to anyone who comes into possession of a copy. This 405 | License will therefore apply, along with any applicable section 7 406 | additional terms, to the whole of the work, and all its parts, 407 | regardless of how they are packaged. This License gives no 408 | permission to license the work in any other way, but it does not 409 | invalidate such permission if you have separately received it. 410 | 411 | d) If the work has interactive user interfaces, each must display 412 | Appropriate Legal Notices; however, if the Program has interactive 413 | interfaces that do not display Appropriate Legal Notices, your 414 | work need not make them do so. 415 | 416 | A compilation of a covered work with other separate and independent 417 | works, which are not by their nature extensions of the covered work, 418 | and which are not combined with it such as to form a larger program, 419 | in or on a volume of a storage or distribution medium, is called an 420 | "aggregate" if the compilation and its resulting copyright are not 421 | used to limit the access or legal rights of the compilation's users 422 | beyond what the individual works permit. Inclusion of a covered work 423 | in an aggregate does not cause this License to apply to the other 424 | parts of the aggregate. 425 | 426 | 6. Conveying Non-Source Forms. 427 | 428 | You may convey a covered work in object code form under the terms 429 | of sections 4 and 5, provided that you also convey the 430 | machine-readable Corresponding Source under the terms of this License, 431 | in one of these ways: 432 | 433 | a) Convey the object code in, or embodied in, a physical product 434 | (including a physical distribution medium), accompanied by the 435 | Corresponding Source fixed on a durable physical medium 436 | customarily used for software interchange. 437 | 438 | b) Convey the object code in, or embodied in, a physical product 439 | (including a physical distribution medium), accompanied by a 440 | written offer, valid for at least three years and valid for as 441 | long as you offer spare parts or customer support for that product 442 | model, to give anyone who possesses the object code either (1) a 443 | copy of the Corresponding Source for all the software in the 444 | product that is covered by this License, on a durable physical 445 | medium customarily used for software interchange, for a price no 446 | more than your reasonable cost of physically performing this 447 | conveying of source, or (2) access to copy the 448 | Corresponding Source from a network server at no charge. 449 | 450 | c) Convey individual copies of the object code with a copy of the 451 | written offer to provide the Corresponding Source. This 452 | alternative is allowed only occasionally and noncommercially, and 453 | only if you received the object code with such an offer, in accord 454 | with subsection 6b. 455 | 456 | d) Convey the object code by offering access from a designated 457 | place (gratis or for a charge), and offer equivalent access to the 458 | Corresponding Source in the same way through the same place at no 459 | further charge. You need not require recipients to copy the 460 | Corresponding Source along with the object code. If the place to 461 | copy the object code is a network server, the Corresponding Source 462 | may be on a different server (operated by you or a third party) 463 | that supports equivalent copying facilities, provided you maintain 464 | clear directions next to the object code saying where to find the 465 | Corresponding Source. Regardless of what server hosts the 466 | Corresponding Source, you remain obligated to ensure that it is 467 | available for as long as needed to satisfy these requirements. 468 | 469 | e) Convey the object code using peer-to-peer transmission, provided 470 | you inform other peers where the object code and Corresponding 471 | Source of the work are being offered to the general public at no 472 | charge under subsection 6d. 473 | 474 | A separable portion of the object code, whose source code is excluded 475 | from the Corresponding Source as a System Library, need not be 476 | included in conveying the object code work. 477 | 478 | A "User Product" is either (1) a "consumer product", which means any 479 | tangible personal property which is normally used for personal, family, 480 | or household purposes, or (2) anything designed or sold for incorporation 481 | into a dwelling. In determining whether a product is a consumer product, 482 | doubtful cases shall be resolved in favor of coverage. For a particular 483 | product received by a particular user, "normally used" refers to a 484 | typical or common use of that class of product, regardless of the status 485 | of the particular user or of the way in which the particular user 486 | actually uses, or expects or is expected to use, the product. A product 487 | is a consumer product regardless of whether the product has substantial 488 | commercial, industrial or non-consumer uses, unless such uses represent 489 | the only significant mode of use of the product. 490 | 491 | "Installation Information" for a User Product means any methods, 492 | procedures, authorization keys, or other information required to install 493 | and execute modified versions of a covered work in that User Product from 494 | a modified version of its Corresponding Source. The information must 495 | suffice to ensure that the continued functioning of the modified object 496 | code is in no case prevented or interfered with solely because 497 | modification has been made. 498 | 499 | If you convey an object code work under this section in, or with, or 500 | specifically for use in, a User Product, and the conveying occurs as 501 | part of a transaction in which the right of possession and use of the 502 | User Product is transferred to the recipient in perpetuity or for a 503 | fixed term (regardless of how the transaction is characterized), the 504 | Corresponding Source conveyed under this section must be accompanied 505 | by the Installation Information. But this requirement does not apply 506 | if neither you nor any third party retains the ability to install 507 | modified object code on the User Product (for example, the work has 508 | been installed in ROM). 509 | 510 | The requirement to provide Installation Information does not include a 511 | requirement to continue to provide support service, warranty, or updates 512 | for a work that has been modified or installed by the recipient, or for 513 | the User Product in which it has been modified or installed. Access to a 514 | network may be denied when the modification itself materially and 515 | adversely affects the operation of the network or violates the rules and 516 | protocols for communication across the network. 517 | 518 | Corresponding Source conveyed, and Installation Information provided, 519 | in accord with this section must be in a format that is publicly 520 | documented (and with an implementation available to the public in 521 | source code form), and must require no special password or key for 522 | unpacking, reading or copying. 523 | 524 | 7. Additional Terms. 525 | 526 | "Additional permissions" are terms that supplement the terms of this 527 | License by making exceptions from one or more of its conditions. 528 | Additional permissions that are applicable to the entire Program shall 529 | be treated as though they were included in this License, to the extent 530 | that they are valid under applicable law. If additional permissions 531 | apply only to part of the Program, that part may be used separately 532 | under those permissions, but the entire Program remains governed by 533 | this License without regard to the additional permissions. 534 | 535 | When you convey a copy of a covered work, you may at your option 536 | remove any additional permissions from that copy, or from any part of 537 | it. (Additional permissions may be written to require their own 538 | removal in certain cases when you modify the work.) You may place 539 | additional permissions on material, added by you to a covered work, 540 | for which you have or can give appropriate copyright permission. 541 | 542 | Notwithstanding any other provision of this License, for material you 543 | add to a covered work, you may (if authorized by the copyright holders of 544 | that material) supplement the terms of this License with terms: 545 | 546 | a) Disclaiming warranty or limiting liability differently from the 547 | terms of sections 15 and 16 of this License; or 548 | 549 | b) Requiring preservation of specified reasonable legal notices or 550 | author attributions in that material or in the Appropriate Legal 551 | Notices displayed by works containing it; or 552 | 553 | c) Prohibiting misrepresentation of the origin of that material, or 554 | requiring that modified versions of such material be marked in 555 | reasonable ways as different from the original version; or 556 | 557 | d) Limiting the use for publicity purposes of names of licensors or 558 | authors of the material; or 559 | 560 | e) Declining to grant rights under trademark law for use of some 561 | trade names, trademarks, or service marks; or 562 | 563 | f) Requiring indemnification of licensors and authors of that 564 | material by anyone who conveys the material (or modified versions of 565 | it) with contractual assumptions of liability to the recipient, for 566 | any liability that these contractual assumptions directly impose on 567 | those licensors and authors. 568 | 569 | All other non-permissive additional terms are considered "further 570 | restrictions" within the meaning of section 10. If the Program as you 571 | received it, or any part of it, contains a notice stating that it is 572 | governed by this License along with a term that is a further 573 | restriction, you may remove that term. If a license document contains 574 | a further restriction but permits relicensing or conveying under this 575 | License, you may add to a covered work material governed by the terms 576 | of that license document, provided that the further restriction does 577 | not survive such relicensing or conveying. 578 | 579 | If you add terms to a covered work in accord with this section, you 580 | must place, in the relevant source files, a statement of the 581 | additional terms that apply to those files, or a notice indicating 582 | where to find the applicable terms. 583 | 584 | Additional terms, permissive or non-permissive, may be stated in the 585 | form of a separately written license, or stated as exceptions; 586 | the above requirements apply either way. 587 | 588 | 8. Termination. 589 | 590 | You may not propagate or modify a covered work except as expressly 591 | provided under this License. Any attempt otherwise to propagate or 592 | modify it is void, and will automatically terminate your rights under 593 | this License (including any patent licenses granted under the third 594 | paragraph of section 11). 595 | 596 | However, if you cease all violation of this License, then your 597 | license from a particular copyright holder is reinstated (a) 598 | provisionally, unless and until the copyright holder explicitly and 599 | finally terminates your license, and (b) permanently, if the copyright 600 | holder fails to notify you of the violation by some reasonable means 601 | prior to 60 days after the cessation. 602 | 603 | Moreover, your license from a particular copyright holder is 604 | reinstated permanently if the copyright holder notifies you of the 605 | violation by some reasonable means, this is the first time you have 606 | received notice of violation of this License (for any work) from that 607 | copyright holder, and you cure the violation prior to 30 days after 608 | your receipt of the notice. 609 | 610 | Termination of your rights under this section does not terminate the 611 | licenses of parties who have received copies or rights from you under 612 | this License. If your rights have been terminated and not permanently 613 | reinstated, you do not qualify to receive new licenses for the same 614 | material under section 10. 615 | 616 | 9. Acceptance Not Required for Having Copies. 617 | 618 | You are not required to accept this License in order to receive or 619 | run a copy of the Program. Ancillary propagation of a covered work 620 | occurring solely as a consequence of using peer-to-peer transmission 621 | to receive a copy likewise does not require acceptance. However, 622 | nothing other than this License grants you permission to propagate or 623 | modify any covered work. These actions infringe copyright if you do 624 | not accept this License. Therefore, by modifying or propagating a 625 | covered work, you indicate your acceptance of this License to do so. 626 | 627 | 10. Automatic Licensing of Downstream Recipients. 628 | 629 | Each time you convey a covered work, the recipient automatically 630 | receives a license from the original licensors, to run, modify and 631 | propagate that work, subject to this License. You are not responsible 632 | for enforcing compliance by third parties with this License. 633 | 634 | An "entity transaction" is a transaction transferring control of an 635 | organization, or substantially all assets of one, or subdividing an 636 | organization, or merging organizations. If propagation of a covered 637 | work results from an entity transaction, each party to that 638 | transaction who receives a copy of the work also receives whatever 639 | licenses to the work the party's predecessor in interest had or could 640 | give under the previous paragraph, plus a right to possession of the 641 | Corresponding Source of the work from the predecessor in interest, if 642 | the predecessor has it or can get it with reasonable efforts. 643 | 644 | You may not impose any further restrictions on the exercise of the 645 | rights granted or affirmed under this License. For example, you may 646 | not impose a license fee, royalty, or other charge for exercise of 647 | rights granted under this License, and you may not initiate litigation 648 | (including a cross-claim or counterclaim in a lawsuit) alleging that 649 | any patent claim is infringed by making, using, selling, offering for 650 | sale, or importing the Program or any portion of it. 651 | 652 | 11. Patents. 653 | 654 | A "contributor" is a copyright holder who authorizes use under this 655 | License of the Program or a work on which the Program is based. The 656 | work thus licensed is called the contributor's "contributor version". 657 | 658 | A contributor's "essential patent claims" are all patent claims 659 | owned or controlled by the contributor, whether already acquired or 660 | hereafter acquired, that would be infringed by some manner, permitted 661 | by this License, of making, using, or selling its contributor version, 662 | but do not include claims that would be infringed only as a 663 | consequence of further modification of the contributor version. For 664 | purposes of this definition, "control" includes the right to grant 665 | patent sublicenses in a manner consistent with the requirements of 666 | this License. 667 | 668 | Each contributor grants you a non-exclusive, worldwide, royalty-free 669 | patent license under the contributor's essential patent claims, to 670 | make, use, sell, offer for sale, import and otherwise run, modify and 671 | propagate the contents of its contributor version. 672 | 673 | In the following three paragraphs, a "patent license" is any express 674 | agreement or commitment, however denominated, not to enforce a patent 675 | (such as an express permission to practice a patent or covenant not to 676 | sue for patent infringement). To "grant" such a patent license to a 677 | party means to make such an agreement or commitment not to enforce a 678 | patent against the party. 679 | 680 | If you convey a covered work, knowingly relying on a patent license, 681 | and the Corresponding Source of the work is not available for anyone 682 | to copy, free of charge and under the terms of this License, through a 683 | publicly available network server or other readily accessible means, 684 | then you must either (1) cause the Corresponding Source to be so 685 | available, or (2) arrange to deprive yourself of the benefit of the 686 | patent license for this particular work, or (3) arrange, in a manner 687 | consistent with the requirements of this License, to extend the patent 688 | license to downstream recipients. "Knowingly relying" means you have 689 | actual knowledge that, but for the patent license, your conveying the 690 | covered work in a country, or your recipient's use of the covered work 691 | in a country, would infringe one or more identifiable patents in that 692 | country that you have reason to believe are valid. 693 | 694 | If, pursuant to or in connection with a single transaction or 695 | arrangement, you convey, or propagate by procuring conveyance of, a 696 | covered work, and grant a patent license to some of the parties 697 | receiving the covered work authorizing them to use, propagate, modify 698 | or convey a specific copy of the covered work, then the patent license 699 | you grant is automatically extended to all recipients of the covered 700 | work and works based on it. 701 | 702 | A patent license is "discriminatory" if it does not include within 703 | the scope of its coverage, prohibits the exercise of, or is 704 | conditioned on the non-exercise of one or more of the rights that are 705 | specifically granted under this License. You may not convey a covered 706 | work if you are a party to an arrangement with a third party that is 707 | in the business of distributing software, under which you make payment 708 | to the third party based on the extent of your activity of conveying 709 | the work, and under which the third party grants, to any of the 710 | parties who would receive the covered work from you, a discriminatory 711 | patent license (a) in connection with copies of the covered work 712 | conveyed by you (or copies made from those copies), or (b) primarily 713 | for and in connection with specific products or compilations that 714 | contain the covered work, unless you entered into that arrangement, 715 | or that patent license was granted, prior to 28 March 2007. 716 | 717 | Nothing in this License shall be construed as excluding or limiting 718 | any implied license or other defenses to infringement that may 719 | otherwise be available to you under applicable patent law. 720 | 721 | 12. No Surrender of Others' Freedom. 722 | 723 | If conditions are imposed on you (whether by court order, agreement or 724 | otherwise) that contradict the conditions of this License, they do not 725 | excuse you from the conditions of this License. If you cannot convey a 726 | covered work so as to satisfy simultaneously your obligations under this 727 | License and any other pertinent obligations, then as a consequence you may 728 | not convey it at all. For example, if you agree to terms that obligate you 729 | to collect a royalty for further conveying from those to whom you convey 730 | the Program, the only way you could satisfy both those terms and this 731 | License would be to refrain entirely from conveying the Program. 732 | 733 | 13. Use with the GNU Affero General Public License. 734 | 735 | Notwithstanding any other provision of this License, you have 736 | permission to link or combine any covered work with a work licensed 737 | under version 3 of the GNU Affero General Public License into a single 738 | combined work, and to convey the resulting work. The terms of this 739 | License will continue to apply to the part which is the covered work, 740 | but the special requirements of the GNU Affero General Public License, 741 | section 13, concerning interaction through a network will apply to the 742 | combination as such. 743 | 744 | 14. Revised Versions of this License. 745 | 746 | The Free Software Foundation may publish revised and/or new versions of 747 | the GNU General Public License from time to time. Such new versions will 748 | be similar in spirit to the present version, but may differ in detail to 749 | address new problems or concerns. 750 | 751 | Each version is given a distinguishing version number. If the 752 | Program specifies that a certain numbered version of the GNU General 753 | Public License "or any later version" applies to it, you have the 754 | option of following the terms and conditions either of that numbered 755 | version or of any later version published by the Free Software 756 | Foundation. If the Program does not specify a version number of the 757 | GNU General Public License, you may choose any version ever published 758 | by the Free Software Foundation. 759 | 760 | If the Program specifies that a proxy can decide which future 761 | versions of the GNU General Public License can be used, that proxy's 762 | public statement of acceptance of a version permanently authorizes you 763 | to choose that version for the Program. 764 | 765 | Later license versions may give you additional or different 766 | permissions. However, no additional obligations are imposed on any 767 | author or copyright holder as a result of your choosing to follow a 768 | later version. 769 | 770 | 15. Disclaimer of Warranty. 771 | 772 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 773 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 774 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 775 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 776 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 777 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 778 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 779 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 780 | 781 | 16. Limitation of Liability. 782 | 783 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 784 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 785 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 786 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 787 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 788 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 789 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 790 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 791 | SUCH DAMAGES. 792 | 793 | 17. Interpretation of Sections 15 and 16. 794 | 795 | If the disclaimer of warranty and limitation of liability provided 796 | above cannot be given local legal effect according to their terms, 797 | reviewing courts shall apply local law that most closely approximates 798 | an absolute waiver of all civil liability in connection with the 799 | Program, unless a warranty or assumption of liability accompanies a 800 | copy of the Program in return for a fee. 801 | 802 | END OF TERMS AND CONDITIONS 803 | 804 | How to Apply These Terms to Your New Programs 805 | 806 | If you develop a new program, and you want it to be of the greatest 807 | possible use to the public, the best way to achieve this is to make it 808 | free software which everyone can redistribute and change under these terms. 809 | 810 | To do so, attach the following notices to the program. It is safest 811 | to attach them to the start of each source file to most effectively 812 | state the exclusion of warranty; and each file should have at least 813 | the "copyright" line and a pointer to where the full notice is found. 814 | 815 | 816 | Copyright (C) 817 | 818 | This program is free software: you can redistribute it and/or modify 819 | it under the terms of the GNU General Public License as published by 820 | the Free Software Foundation, either version 3 of the License, or 821 | (at your option) any later version. 822 | 823 | This program is distributed in the hope that it will be useful, 824 | but WITHOUT ANY WARRANTY; without even the implied warranty of 825 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 826 | GNU General Public License for more details. 827 | 828 | You should have received a copy of the GNU General Public License 829 | along with this program. If not, see . 830 | 831 | Also add information on how to contact you by electronic and paper mail. 832 | 833 | If the program does terminal interaction, make it output a short 834 | notice like this when it starts in an interactive mode: 835 | 836 | Copyright (C) 837 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 838 | This is free software, and you are welcome to redistribute it 839 | under certain conditions; type `show c' for details. 840 | 841 | The hypothetical commands `show w' and `show c' should show the appropriate 842 | parts of the General Public License. Of course, your program's commands 843 | might be different; for a GUI interface, you would use an "about box". 844 | 845 | You should also get your employer (if you work as a programmer) or school, 846 | if any, to sign a "copyright disclaimer" for the program, if necessary. 847 | For more information on this, and how to apply and follow the GNU GPL, see 848 | . 849 | 850 | The GNU General Public License does not permit incorporating your program 851 | into proprietary programs. If your program is a subroutine library, you 852 | may consider it more useful to permit linking proprietary applications with 853 | the library. If this is what you want to do, use the GNU Lesser General 854 | Public License instead of this License. But first, please read 855 | . 856 | 857 | ********************************************************************** 858 | ********************************************************************** 859 | -------------------------------------------------------------------------------- /src/Milon/Barcode/Datamatrix.php: -------------------------------------------------------------------------------- 1 | . 29 | // 30 | // See LICENSE.TXT file for more information. 31 | // ------------------------------------------------------------------- 32 | // 33 | // DESCRIPTION : 34 | // 35 | // Class to create DataMatrix ECC 200 barcode arrays for TCPDF class. 36 | // DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code. 37 | //============================================================+ 38 | 39 | /** 40 | * @file 41 | * Class to create DataMatrix ECC 200 barcode arrays for TCPDF class. 42 | * DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code. 43 | * 44 | * @package com.tecnick.tcpdf 45 | * @author Nicola Asuni 46 | * @version 1.0.008 47 | */ 48 | 49 | // custom definitions 50 | if (!defined('DATAMATRIXDEFS')) { 51 | 52 | /** 53 | * Indicate that definitions for this class are set 54 | */ 55 | define('DATAMATRIXDEFS', true); 56 | 57 | // ----------------------------------------------------- 58 | 59 | } // end of custom definitions 60 | 61 | // #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# 62 | 63 | 64 | /** 65 | * ASCII encoding: ASCII character 0 to 127 (1 byte per CW) 66 | */ 67 | define('ENC_ASCII', 0); 68 | 69 | /** 70 | * C40 encoding: Upper-case alphanumeric (3/2 bytes per CW) 71 | */ 72 | define('ENC_C40', 1); 73 | 74 | /** 75 | * TEXT encoding: Lower-case alphanumeric (3/2 bytes per CW) 76 | */ 77 | define('ENC_TXT', 2); 78 | 79 | /** 80 | * X12 encoding: ANSI X12 (3/2 byte per CW) 81 | */ 82 | define('ENC_X12', 3); 83 | 84 | /** 85 | * EDIFACT encoding: ASCII character 32 to 94 (4/3 bytes per CW) 86 | */ 87 | define('ENC_EDF', 4); 88 | 89 | /** 90 | * BASE 256 encoding: ASCII character 0 to 255 (1 byte per CW) 91 | */ 92 | define('ENC_BASE256', 5); 93 | 94 | /** 95 | * ASCII extended encoding: ASCII character 128 to 255 (1/2 byte per CW) 96 | */ 97 | define('ENC_ASCII_EXT', 6); 98 | 99 | /** 100 | * ASCII number encoding: ASCII digits (2 bytes per CW) 101 | */ 102 | define('ENC_ASCII_NUM', 7); 103 | 104 | /** 105 | * @class Datamatrix 106 | * Class to create DataMatrix ECC 200 barcode arrays for TCPDF class. 107 | * DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code. 108 | * 109 | * @package com.tecnick.tcpdf 110 | * @author Nicola Asuni 111 | * @version 1.0.004 112 | */ 113 | class Datamatrix { 114 | 115 | /** 116 | * Barcode array to be returned which is readable by TCPDF. 117 | * @protected 118 | */ 119 | protected $barcode_array = array(); 120 | 121 | /** 122 | * Store last used encoding for data codewords. 123 | * @protected 124 | */ 125 | protected $last_enc = ENC_ASCII; 126 | 127 | /** 128 | * Table of Data Matrix ECC 200 Symbol Attributes:
      129 | *
    • total matrix rows (including finder pattern)
    • 130 | *
    • total matrix cols (including finder pattern)
    • 131 | *
    • total matrix rows (without finder pattern)
    • 132 | *
    • total matrix cols (without finder pattern)
    • 133 | *
    • region data rows (with finder pattern)
    • 134 | *
    • region data col (with finder pattern)
    • 135 | *
    • region data rows (without finder pattern)
    • 136 | *
    • region data col (without finder pattern)
    • 137 | *
    • horizontal regions
    • 138 | *
    • vertical regions
    • 139 | *
    • regions
    • 140 | *
    • data codewords
    • 141 | *
    • error codewords
    • 142 | *
    • blocks
    • 143 | *
    • data codewords per block
    • 144 | *
    • error codewords per block
    • 145 | *
    146 | * @protected 147 | */ 148 | protected $symbattr = array( 149 | // square form --------------------------------------------------------------------------------------- 150 | array(0x00a,0x00a,0x008,0x008,0x00a,0x00a,0x008,0x008,0x001,0x001,0x001,0x003,0x005,0x001,0x003,0x005), // 10x10 151 | array(0x00c,0x00c,0x00a,0x00a,0x00c,0x00c,0x00a,0x00a,0x001,0x001,0x001,0x005,0x007,0x001,0x005,0x007), // 12x12 152 | array(0x00e,0x00e,0x00c,0x00c,0x00e,0x00e,0x00c,0x00c,0x001,0x001,0x001,0x008,0x00a,0x001,0x008,0x00a), // 14x14 153 | array(0x010,0x010,0x00e,0x00e,0x010,0x010,0x00e,0x00e,0x001,0x001,0x001,0x00c,0x00c,0x001,0x00c,0x00c), // 16x16 154 | array(0x012,0x012,0x010,0x010,0x012,0x012,0x010,0x010,0x001,0x001,0x001,0x012,0x00e,0x001,0x012,0x00e), // 18x18 155 | array(0x014,0x014,0x012,0x012,0x014,0x014,0x012,0x012,0x001,0x001,0x001,0x016,0x012,0x001,0x016,0x012), // 20x20 156 | array(0x016,0x016,0x014,0x014,0x016,0x016,0x014,0x014,0x001,0x001,0x001,0x01e,0x014,0x001,0x01e,0x014), // 22x22 157 | array(0x018,0x018,0x016,0x016,0x018,0x018,0x016,0x016,0x001,0x001,0x001,0x024,0x018,0x001,0x024,0x018), // 24x24 158 | array(0x01a,0x01a,0x018,0x018,0x01a,0x01a,0x018,0x018,0x001,0x001,0x001,0x02c,0x01c,0x001,0x02c,0x01c), // 26x26 159 | array(0x020,0x020,0x01c,0x01c,0x010,0x010,0x00e,0x00e,0x002,0x002,0x004,0x03e,0x024,0x001,0x03e,0x024), // 32x32 160 | array(0x024,0x024,0x020,0x020,0x012,0x012,0x010,0x010,0x002,0x002,0x004,0x056,0x02a,0x001,0x056,0x02a), // 36x36 161 | array(0x028,0x028,0x024,0x024,0x014,0x014,0x012,0x012,0x002,0x002,0x004,0x072,0x030,0x001,0x072,0x030), // 40x40 162 | array(0x02c,0x02c,0x028,0x028,0x016,0x016,0x014,0x014,0x002,0x002,0x004,0x090,0x038,0x001,0x090,0x038), // 44x44 163 | array(0x030,0x030,0x02c,0x02c,0x018,0x018,0x016,0x016,0x002,0x002,0x004,0x0ae,0x044,0x001,0x0ae,0x044), // 48x48 164 | array(0x034,0x034,0x030,0x030,0x01a,0x01a,0x018,0x018,0x002,0x002,0x004,0x0cc,0x054,0x002,0x066,0x02a), // 52x52 165 | array(0x040,0x040,0x038,0x038,0x010,0x010,0x00e,0x00e,0x004,0x004,0x010,0x118,0x070,0x002,0x08c,0x038), // 64x64 166 | array(0x048,0x048,0x040,0x040,0x012,0x012,0x010,0x010,0x004,0x004,0x010,0x170,0x090,0x004,0x05c,0x024), // 72x72 167 | array(0x050,0x050,0x048,0x048,0x014,0x014,0x012,0x012,0x004,0x004,0x010,0x1c8,0x0c0,0x004,0x072,0x030), // 80x80 168 | array(0x058,0x058,0x050,0x050,0x016,0x016,0x014,0x014,0x004,0x004,0x010,0x240,0x0e0,0x004,0x090,0x038), // 88x88 169 | array(0x060,0x060,0x058,0x058,0x018,0x018,0x016,0x016,0x004,0x004,0x010,0x2b8,0x110,0x004,0x0ae,0x044), // 96x96 170 | array(0x068,0x068,0x060,0x060,0x01a,0x01a,0x018,0x018,0x004,0x004,0x010,0x330,0x150,0x006,0x088,0x038), // 104x104 171 | array(0x078,0x078,0x06c,0x06c,0x014,0x014,0x012,0x012,0x006,0x006,0x024,0x41a,0x198,0x006,0x0af,0x044), // 120x120 172 | array(0x084,0x084,0x078,0x078,0x016,0x016,0x014,0x014,0x006,0x006,0x024,0x518,0x1f0,0x008,0x0a3,0x03e), // 132x132 173 | array(0x090,0x090,0x084,0x084,0x018,0x018,0x016,0x016,0x006,0x006,0x024,0x616,0x26c,0x00a,0x09c,0x03e), // 144x144 174 | // rectangular form (currently unused) --------------------------------------------------------------------------- 175 | array(0x008,0x012,0x006,0x010,0x008,0x012,0x006,0x010,0x001,0x001,0x001,0x005,0x007,0x001,0x005,0x007), // 8x18 176 | array(0x008,0x020,0x006,0x01c,0x008,0x010,0x006,0x00e,0x001,0x002,0x002,0x00a,0x00b,0x001,0x00a,0x00b), // 8x32 177 | array(0x00c,0x01a,0x00a,0x018,0x00c,0x01a,0x00a,0x018,0x001,0x001,0x001,0x010,0x00e,0x001,0x010,0x00e), // 12x26 178 | array(0x00c,0x024,0x00a,0x020,0x00c,0x012,0x00a,0x010,0x001,0x002,0x002,0x00c,0x012,0x001,0x00c,0x012), // 12x36 179 | array(0x010,0x024,0x00e,0x020,0x010,0x012,0x00e,0x010,0x001,0x002,0x002,0x020,0x018,0x001,0x020,0x018), // 16x36 180 | array(0x010,0x030,0x00e,0x02c,0x010,0x018,0x00e,0x016,0x001,0x002,0x002,0x031,0x01c,0x001,0x031,0x01c) // 16x48 181 | ); 182 | 183 | /** 184 | * Map encodation modes whit character sets. 185 | * @protected 186 | */ 187 | protected $chset_id = array(ENC_C40 => 'C40', ENC_TXT => 'TXT', ENC_X12 =>'X12'); 188 | 189 | /** 190 | * Basic set of characters for each encodation mode. 191 | * @protected 192 | */ 193 | protected $chset = array( 194 | 'C40' => array( // Basic set for C40 ---------------------------------------------------------------------------- 195 | 'S1'=>0x00,'S2'=>0x01,'S3'=>0x02,0x20=>0x03,0x30=>0x04,0x31=>0x05,0x32=>0x06,0x33=>0x07,0x34=>0x08,0x35=>0x09, // 196 | 0x36=>0x0a,0x37=>0x0b,0x38=>0x0c,0x39=>0x0d,0x41=>0x0e,0x42=>0x0f,0x43=>0x10,0x44=>0x11,0x45=>0x12,0x46=>0x13, // 197 | 0x47=>0x14,0x48=>0x15,0x49=>0x16,0x4a=>0x17,0x4b=>0x18,0x4c=>0x19,0x4d=>0x1a,0x4e=>0x1b,0x4f=>0x1c,0x50=>0x1d, // 198 | 0x51=>0x1e,0x52=>0x1f,0x53=>0x20,0x54=>0x21,0x55=>0x22,0x56=>0x23,0x57=>0x24,0x58=>0x25,0x59=>0x26,0x5a=>0x27),// 199 | 'TXT' => array( // Basic set for TEXT --------------------------------------------------------------------------- 200 | 'S1'=>0x00,'S2'=>0x01,'S3'=>0x02,0x20=>0x03,0x30=>0x04,0x31=>0x05,0x32=>0x06,0x33=>0x07,0x34=>0x08,0x35=>0x09, // 201 | 0x36=>0x0a,0x37=>0x0b,0x38=>0x0c,0x39=>0x0d,0x61=>0x0e,0x62=>0x0f,0x63=>0x10,0x64=>0x11,0x65=>0x12,0x66=>0x13, // 202 | 0x67=>0x14,0x68=>0x15,0x69=>0x16,0x6a=>0x17,0x6b=>0x18,0x6c=>0x19,0x6d=>0x1a,0x6e=>0x1b,0x6f=>0x1c,0x70=>0x1d, // 203 | 0x71=>0x1e,0x72=>0x1f,0x73=>0x20,0x74=>0x21,0x75=>0x22,0x76=>0x23,0x77=>0x24,0x78=>0x25,0x79=>0x26,0x7a=>0x27),// 204 | 'SH1' => array( // Shift 1 set ---------------------------------------------------------------------------------- 205 | 0x00=>0x00,0x01=>0x01,0x02=>0x02,0x03=>0x03,0x04=>0x04,0x05=>0x05,0x06=>0x06,0x07=>0x07,0x08=>0x08,0x09=>0x09, // 206 | 0x0a=>0x0a,0x0b=>0x0b,0x0c=>0x0c,0x0d=>0x0d,0x0e=>0x0e,0x0f=>0x0f,0x10=>0x10,0x11=>0x11,0x12=>0x12,0x13=>0x13, // 207 | 0x14=>0x14,0x15=>0x15,0x16=>0x16,0x17=>0x17,0x18=>0x18,0x19=>0x19,0x1a=>0x1a,0x1b=>0x1b,0x1c=>0x1c,0x1d=>0x1d, // 208 | 0x1e=>0x1e,0x1f=>0x1f), // 209 | 'SH2' => array( // Shift 2 set ---------------------------------------------------------------------------------- 210 | 0x21=>0x00,0x22=>0x01,0x23=>0x02,0x24=>0x03,0x25=>0x04,0x26=>0x05,0x27=>0x06,0x28=>0x07,0x29=>0x08,0x2a=>0x09, // 211 | 0x2b=>0x0a,0x2c=>0x0b,0x2d=>0x0c,0x2e=>0x0d,0x2f=>0x0e,0x3a=>0x0f,0x3b=>0x10,0x3c=>0x11,0x3d=>0x12,0x3e=>0x13, // 212 | 0x3f=>0x14,0x40=>0x15,0x5b=>0x16,0x5c=>0x17,0x5d=>0x18,0x5e=>0x19,0x5f=>0x1a,'F1'=>0x1b,'US'=>0x1e), // 213 | 'S3C' => array( // Shift 3 set for C40 -------------------------------------------------------------------------- 214 | 0x60=>0x00,0x61=>0x01,0x62=>0x02,0x63=>0x03,0x64=>0x04,0x65=>0x05,0x66=>0x06,0x67=>0x07,0x68=>0x08,0x69=>0x09, // 215 | 0x6a=>0x0a,0x6b=>0x0b,0x6c=>0x0c,0x6d=>0x0d,0x6e=>0x0e,0x6f=>0x0f,0x70=>0x10,0x71=>0x11,0x72=>0x12,0x73=>0x13, // 216 | 0x74=>0x14,0x75=>0x15,0x76=>0x16,0x77=>0x17,0x78=>0x18,0x79=>0x19,0x7a=>0x1a,0x7b=>0x1b,0x7c=>0x1c,0x7d=>0x1d, // 217 | 0x7e=>0x1e,0x7f=>0x1f), 218 | 'S3T' => array( // Shift 3 set for TEXT ------------------------------------------------------------------------- 219 | 0x60=>0x00,0x41=>0x01,0x42=>0x02,0x43=>0x03,0x44=>0x04,0x45=>0x05,0x46=>0x06,0x47=>0x07,0x48=>0x08,0x49=>0x09, // 220 | 0x4a=>0x0a,0x4b=>0x0b,0x4c=>0x0c,0x4d=>0x0d,0x4e=>0x0e,0x4f=>0x0f,0x50=>0x10,0x51=>0x11,0x52=>0x12,0x53=>0x13, // 221 | 0x54=>0x14,0x55=>0x15,0x56=>0x16,0x57=>0x17,0x58=>0x18,0x59=>0x19,0x5a=>0x1a,0x7b=>0x1b,0x7c=>0x1c,0x7d=>0x1d, // 222 | 0x7e=>0x1e,0x7f=>0x1f), // 223 | 'X12' => array( // Set for X12 ---------------------------------------------------------------------------------- 224 | 0x0d=>0x00,0x2a=>0x01,0x3e=>0x02,0x20=>0x03,0x30=>0x04,0x31=>0x05,0x32=>0x06,0x33=>0x07,0x34=>0x08,0x35=>0x09, // 225 | 0x36=>0x0a,0x37=>0x0b,0x38=>0x0c,0x39=>0x0d,0x41=>0x0e,0x42=>0x0f,0x43=>0x10,0x44=>0x11,0x45=>0x12,0x46=>0x13, // 226 | 0x47=>0x14,0x48=>0x15,0x49=>0x16,0x4a=>0x17,0x4b=>0x18,0x4c=>0x19,0x4d=>0x1a,0x4e=>0x1b,0x4f=>0x1c,0x50=>0x1d, // 227 | 0x51=>0x1e,0x52=>0x1f,0x53=>0x20,0x54=>0x21,0x55=>0x22,0x56=>0x23,0x57=>0x24,0x58=>0x25,0x59=>0x26,0x5a=>0x27) // 228 | ); 229 | 230 | // ----------------------------------------------------------------------------- 231 | 232 | /** 233 | * This is the class constructor. 234 | * Creates a datamatrix object 235 | * @param $code (string) Code to represent using Datamatrix. 236 | * @public 237 | */ 238 | public function __construct($code) { 239 | $barcode_array = array(); 240 | if ((is_null($code)) OR ($code == '\0') OR ($code == '')) { 241 | return false; 242 | } 243 | // get data codewords 244 | $cw = $this->getHighLevelEncoding($code); 245 | // number of data codewords 246 | $nd = count($cw); 247 | // check size 248 | if ($nd > 1558) { 249 | return false; 250 | } 251 | // get minimum required matrix size. 252 | foreach ($this->symbattr as $params) { 253 | if ($params[11] >= $nd) { 254 | break; 255 | } 256 | } 257 | if ($params[11] < $nd) { 258 | // too much data 259 | return false; 260 | } elseif ($params[11] > $nd) { 261 | // add padding 262 | if ((($params[11] - $nd) > 1) AND ($cw[($nd - 1)] != 254)) { 263 | if ($this->last_enc == ENC_EDF) { 264 | // switch to ASCII encoding 265 | $cw[] = 124; 266 | ++$nd; 267 | } elseif (($this->last_enc != ENC_ASCII) AND ($this->last_enc != ENC_BASE256)) { 268 | // switch to ASCII encoding 269 | $cw[] = 254; 270 | ++$nd; 271 | } 272 | } 273 | if ($params[11] > $nd) { 274 | // add first pad 275 | $cw[] = 129; 276 | ++$nd; 277 | // add remaining pads 278 | for ($i = $nd; $i < $params[11]; ++$i) { 279 | $cw[] = $this->get253StateCodeword(129, $i); 280 | } 281 | } 282 | } 283 | // add error correction codewords 284 | $cw = $this->getErrorCorrection($cw, $params[13], $params[14], $params[15]); 285 | // initialize empty arrays 286 | $grid = array_fill(0, ($params[2] * $params[3]), 0); 287 | // get placement map 288 | $places = $this->getPlacementMap($params[2], $params[3]); 289 | // fill the grid with data 290 | $grid = array(); 291 | $i = 0; 292 | // region data row max index 293 | $rdri = ($params[4] - 1); 294 | // region data column max index 295 | $rdci = ($params[5] - 1); 296 | // for each vertical region 297 | for ($vr = 0; $vr < $params[9]; ++$vr) { 298 | // for each row on region 299 | for ($r = 0; $r < $params[4]; ++$r) { 300 | // get row 301 | $row = (($vr * $params[4]) + $r); 302 | // for each horizontal region 303 | for ($hr = 0; $hr < $params[8]; ++$hr) { 304 | // for each column on region 305 | for ($c = 0; $c < $params[5]; ++$c) { 306 | // get column 307 | $col = (($hr * $params[5]) + $c); 308 | // braw bits by case 309 | if ($r == 0) { 310 | // top finder pattern 311 | if ($c % 2) { 312 | $grid[$row][$col] = 0; 313 | } else { 314 | $grid[$row][$col] = 1; 315 | } 316 | } elseif ($r == $rdri) { 317 | // bottom finder pattern 318 | $grid[$row][$col] = 1; 319 | } elseif ($c == 0) { 320 | // left finder pattern 321 | $grid[$row][$col] = 1; 322 | } elseif ($c == $rdci) { 323 | // right finder pattern 324 | if ($r % 2) { 325 | $grid[$row][$col] = 1; 326 | } else { 327 | $grid[$row][$col] = 0; 328 | } 329 | } else { // data bit 330 | if ($places[$i] < 2) { 331 | $grid[$row][$col] = $places[$i]; 332 | } else { 333 | // codeword ID 334 | $cw_id = (floor($places[$i] / 10) - 1); 335 | // codeword BIT mask 336 | $cw_bit = pow(2, (8 - ($places[$i] % 10))); 337 | $grid[$row][$col] = (($cw[$cw_id] & $cw_bit) == 0) ? 0 : 1; 338 | } 339 | ++$i; 340 | } 341 | } 342 | } 343 | } 344 | } 345 | $this->barcode_array['num_rows'] = $params[0]; 346 | $this->barcode_array['num_cols'] = $params[1]; 347 | $this->barcode_array['bcode'] = $grid; 348 | } 349 | 350 | /** 351 | * Returns a barcode array which is readable by TCPDF 352 | * @return array barcode array readable by TCPDF; 353 | * @public 354 | */ 355 | public function getBarcodeArray() { 356 | return $this->barcode_array; 357 | } 358 | 359 | /** 360 | * Product of two numbers in a Power-of-Two Galois Field 361 | * @param $a (int) first number to multiply. 362 | * @param $b (int) second number to multiply. 363 | * @param $log (array) Log table. 364 | * @param $alog (array) Anti-Log table. 365 | * @param $gf (array) Number of Factors of the Reed-Solomon polynomial. 366 | * @return int product 367 | * @protected 368 | */ 369 | protected function getGFProduct($a, $b, $log, $alog, $gf) { 370 | if (($a == 0) OR ($b == 0)) { 371 | return 0; 372 | } 373 | return ($alog[($log[$a] + $log[$b]) % ($gf - 1)]); 374 | } 375 | 376 | /** 377 | * Add error correction codewords to data codewords array (ANNEX E). 378 | * @param $wd (array) Array of datacodewords. 379 | * @param $nb (int) Number of blocks. 380 | * @param $nd (int) Number of data codewords per block. 381 | * @param $nc (int) Number of correction codewords per block. 382 | * @param $gf (int) numner of fields on log/antilog table (power of 2). 383 | * @param $pp (int) The value of its prime modulus polynomial (301 for ECC200). 384 | * @return array data codewords + error codewords 385 | * @protected 386 | */ 387 | protected function getErrorCorrection($wd, $nb, $nd, $nc, $gf=256, $pp=301) { 388 | // generate the log ($log) and antilog ($alog) tables 389 | $log[0] = 0; 390 | $alog[0] = 1; 391 | for ($i = 1; $i < $gf; ++$i) { 392 | $alog[$i] = ($alog[($i - 1)] * 2); 393 | if ($alog[$i] >= $gf) { 394 | $alog[$i] ^= $pp; 395 | } 396 | $log[$alog[$i]] = $i; 397 | } 398 | ksort($log); 399 | // generate the polynomial coefficients (c) 400 | $c = array_fill(0, ($nc + 1), 0); 401 | $c[0] = 1; 402 | for ($i = 1; $i <= $nc; ++$i) { 403 | $c[$i] = $c[($i-1)]; 404 | for ($j = ($i - 1); $j >= 1; --$j) { 405 | $c[$j] = $c[($j - 1)] ^ $this->getGFProduct($c[$j], $alog[$i], $log, $alog, $gf); 406 | } 407 | $c[0] = $this->getGFProduct($c[0], $alog[$i], $log, $alog, $gf); 408 | } 409 | ksort($c); 410 | // total number of data codewords 411 | $num_wd = ($nb * $nd); 412 | // total number of error codewords 413 | $num_we = ($nb * $nc); 414 | // for each block 415 | for ($b = 0; $b < $nb; ++$b) { 416 | // create interleaved data block 417 | $block = array(); 418 | for ($n = $b; $n < $num_wd; $n += $nb) { 419 | $block[] = $wd[$n]; 420 | } 421 | // initialize error codewords 422 | $we = array_fill(0, ($nc + 1), 0); 423 | // calculate error correction codewords for this block 424 | for ($i = 0; $i < $nd; ++$i) { 425 | $k = ($we[0] ^ $block[$i]); 426 | for ($j = 0; $j < $nc; ++$j) { 427 | $we[$j] = ($we[($j + 1)] ^ $this->getGFProduct($k, $c[($nc - $j - 1)], $log, $alog, $gf)); 428 | } 429 | } 430 | // add error codewords at the end of data codewords 431 | $j = 0; 432 | for ($i = $b; $i < $num_we; $i += $nb) { 433 | $wd[($num_wd + $i)] = $we[$j]; 434 | ++$j; 435 | } 436 | } 437 | // reorder codewords 438 | ksort($wd); 439 | return $wd; 440 | } 441 | 442 | /** 443 | * Return the 253-state codeword 444 | * @param $cwpad (int) Pad codeword. 445 | * @param $cwpos (int) Number of data codewords from the beginning of encoded data. 446 | * @return pad codeword 447 | * @protected 448 | */ 449 | protected function get253StateCodeword($cwpad, $cwpos) { 450 | $pad = ($cwpad + (((149 * $cwpos) % 253) + 1)); 451 | if ($pad > 254) { 452 | $pad -= 254; 453 | } 454 | return $pad; 455 | } 456 | 457 | /** 458 | * Return the 255-state codeword 459 | * @param $cwpad (int) Pad codeword. 460 | * @param $cwpos (int) Number of data codewords from the beginning of encoded data. 461 | * @return pad codeword 462 | * @protected 463 | */ 464 | protected function get255StateCodeword($cwpad, $cwpos) { 465 | $pad = ($cwpad + (((149 * $cwpos) % 255) + 1)); 466 | if ($pad > 255) { 467 | $pad -= 256; 468 | } 469 | return $pad; 470 | } 471 | 472 | /** 473 | * Returns true if the char belongs to the selected mode 474 | * @param $chr (int) Character (byte) to check. 475 | * @param $mode (int) Current encoding mode. 476 | * @return boolean true if the char is of the selected mode. 477 | * @protected 478 | */ 479 | protected function isCharMode($chr, $mode) { 480 | $status = false; 481 | switch ($mode) { 482 | case ENC_ASCII: { // ASCII character 0 to 127 483 | $status = (($chr >= 0) AND ($chr <= 127)); 484 | break; 485 | } 486 | case ENC_C40: { // Upper-case alphanumeric 487 | $status = (($chr == 32) OR (($chr >= 48) AND ($chr <= 57)) OR (($chr >= 65) AND ($chr <= 90))); 488 | break; 489 | } 490 | case ENC_TXT: { // Lower-case alphanumeric 491 | $status = (($chr == 32) OR (($chr >= 48) AND ($chr <= 57)) OR (($chr >= 97) AND ($chr <= 122))); 492 | break; 493 | } 494 | case ENC_X12: { // ANSI X12 495 | $status = (($chr == 13) OR ($chr == 42) OR ($chr == 62)); 496 | break; 497 | } 498 | case ENC_EDF: { // ASCII character 32 to 94 499 | $status = (($chr >= 32) AND ($chr <= 94)); 500 | break; 501 | } 502 | case ENC_BASE256: { // Function character (FNC1, Structured Append, Reader Program, or Code Page) 503 | $status = (($chr == 232) OR ($chr == 233) OR ($chr == 234) OR ($chr == 241)); 504 | break; 505 | } 506 | case ENC_ASCII_EXT: { // ASCII character 128 to 255 507 | $status = (($chr >= 128) AND ($chr <= 255)); 508 | break; 509 | } 510 | case ENC_ASCII_NUM: { // ASCII digits 511 | $status = (($chr >= 48) AND ($chr <= 57)); 512 | break; 513 | } 514 | } 515 | return $status; 516 | } 517 | 518 | /** 519 | * The look-ahead test scans the data to be encoded to find the best mode (Annex P - steps from J to S). 520 | * @param $data (string) data to encode 521 | * @param $pos (int) current position 522 | * @param $mode (int) current encoding mode 523 | * @return int encoding mode 524 | * @protected 525 | */ 526 | protected function lookAheadTest($data, $pos, $mode) { 527 | $data_length = strlen($data); 528 | if ($pos >= $data_length) { 529 | return $mode; 530 | } 531 | $charscount = 0; // count processed chars 532 | // STEP J 533 | if ($mode == ENC_ASCII) { 534 | $numch = array(0, 1, 1, 1, 1, 1.25); 535 | } else { 536 | $numch = array(1, 2, 2, 2, 2, 2.25); 537 | $numch[$mode] = 0; 538 | } 539 | while (true) { 540 | // STEP K 541 | if (($pos + $charscount) == $data_length) { 542 | if ($numch[ENC_ASCII] <= ceil(min($numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_X12], $numch[ENC_EDF], $numch[ENC_BASE256]))) { 543 | return ENC_ASCII; 544 | } 545 | if ($numch[ENC_BASE256] < ceil(min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_X12], $numch[ENC_EDF]))) { 546 | return ENC_BASE256; 547 | } 548 | if ($numch[ENC_EDF] < ceil(min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_X12], $numch[ENC_BASE256]))) { 549 | return ENC_EDF; 550 | } 551 | if ($numch[ENC_TXT] < ceil(min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_X12], $numch[ENC_EDF], $numch[ENC_BASE256]))) { 552 | return ENC_TXT; 553 | } 554 | if ($numch[ENC_X12] < ceil(min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_EDF], $numch[ENC_BASE256]))) { 555 | return ENC_X12; 556 | } 557 | return ENC_C40; 558 | } 559 | // get char 560 | $chr = ord($data[$pos + $charscount]); 561 | $charscount++; 562 | // STEP L 563 | if ($this->isCharMode($chr, ENC_ASCII_NUM)) { 564 | $numch[ENC_ASCII] += (1 / 2); 565 | } elseif ($this->isCharMode($chr, ENC_ASCII_EXT)) { 566 | $numch[ENC_ASCII] = ceil($numch[ENC_ASCII]); 567 | $numch[ENC_ASCII] += 2; 568 | } else { 569 | $numch[ENC_ASCII] = ceil($numch[ENC_ASCII]); 570 | $numch[ENC_ASCII] += 1; 571 | } 572 | // STEP M 573 | if ($this->isCharMode($chr, ENC_C40)) { 574 | $numch[ENC_C40] += (2 / 3); 575 | } elseif ($this->isCharMode($chr, ENC_ASCII_EXT)) { 576 | $numch[ENC_C40] += (8 / 3); 577 | } else { 578 | $numch[ENC_C40] += (4 / 3); 579 | } 580 | // STEP N 581 | if ($this->isCharMode($chr, ENC_TXT)) { 582 | $numch[ENC_TXT] += (2 / 3); 583 | } elseif ($this->isCharMode($chr, ENC_ASCII_EXT)) { 584 | $numch[ENC_TXT] += (8 / 3); 585 | } else { 586 | $numch[ENC_TXT] += (4 / 3); 587 | } 588 | // STEP O 589 | if ($this->isCharMode($chr, ENC_X12) OR $this->isCharMode($chr, ENC_C40)) { 590 | $numch[ENC_X12] += (2 / 3); 591 | } elseif ($this->isCharMode($chr, ENC_ASCII_EXT)) { 592 | $numch[ENC_X12] += (13 / 3); 593 | } else { 594 | $numch[ENC_X12] += (10 / 3); 595 | } 596 | // STEP P 597 | if ($this->isCharMode($chr, ENC_EDF)) { 598 | $numch[ENC_EDF] += (3 / 4); 599 | } elseif ($this->isCharMode($chr, ENC_ASCII_EXT)) { 600 | $numch[ENC_EDF] += (17 / 4); 601 | } else { 602 | $numch[ENC_EDF] += (13 / 4); 603 | } 604 | // STEP Q 605 | if ($this->isCharMode($chr, ENC_BASE256)) { 606 | $numch[ENC_BASE256] += 4; 607 | } else { 608 | $numch[ENC_BASE256] += 1; 609 | } 610 | // STEP R 611 | if ($charscount >= 4) { 612 | if (($numch[ENC_ASCII] + 1) <= min($numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_X12], $numch[ENC_EDF], $numch[ENC_BASE256])) { 613 | return ENC_ASCII; 614 | } 615 | if ((($numch[ENC_BASE256] + 1) <= $numch[ENC_ASCII]) 616 | OR (($numch[ENC_BASE256] + 1) < min($numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_X12], $numch[ENC_EDF]))) { 617 | return ENC_BASE256; 618 | } 619 | if (($numch[ENC_EDF] + 1) < min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_X12], $numch[ENC_BASE256])) { 620 | return ENC_EDF; 621 | } 622 | if (($numch[ENC_TXT] + 1) < min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_X12], $numch[ENC_EDF], $numch[ENC_BASE256])) { 623 | return ENC_TXT; 624 | } 625 | if (($numch[ENC_X12] + 1) < min($numch[ENC_ASCII], $numch[ENC_C40], $numch[ENC_TXT], $numch[ENC_EDF], $numch[ENC_BASE256])) { 626 | return ENC_X12; 627 | } 628 | if (($numch[ENC_C40] + 1) < min($numch[ENC_ASCII], $numch[ENC_TXT], $numch[ENC_EDF], $numch[ENC_BASE256])) { 629 | if ($numch[ENC_C40] < $numch[ENC_X12]) { 630 | return ENC_C40; 631 | } 632 | if ($numch[ENC_C40] == $numch[ENC_X12]) { 633 | $k = ($pos + $charscount + 1); 634 | while ($k < $data_length) { 635 | $tmpchr = ord($data[$k]); 636 | if ($this->isCharMode($tmpchr, ENC_X12)) { 637 | return ENC_X12; 638 | } elseif (!($this->isCharMode($tmpchr, ENC_X12) OR $this->isCharMode($tmpchr, ENC_C40))) { 639 | break; 640 | } 641 | ++$k; 642 | } 643 | return ENC_C40; 644 | } 645 | } 646 | } 647 | } // end of while 648 | } 649 | 650 | /** 651 | * Get the switching codeword to a new encoding mode (latch codeword) 652 | * @param $mode (int) New encoding mode. 653 | * @return (int) Switch codeword. 654 | * @protected 655 | */ 656 | protected function getSwitchEncodingCodeword($mode) { 657 | switch ($mode) { 658 | case ENC_ASCII: { // ASCII character 0 to 127 659 | $cw = 254; 660 | if ($this->last_enc == ENC_EDF) { 661 | $cw = 124; 662 | } 663 | break; 664 | } 665 | case ENC_C40: { // Upper-case alphanumeric 666 | $cw = 230; 667 | break; 668 | } 669 | case ENC_TXT: { // Lower-case alphanumeric 670 | $cw = 239; 671 | break; 672 | } 673 | case ENC_X12: { // ANSI X12 674 | $cw = 238; 675 | break; 676 | } 677 | case ENC_EDF: { // ASCII character 32 to 94 678 | $cw = 240; 679 | break; 680 | } 681 | case ENC_BASE256: { // Function character (FNC1, Structured Append, Reader Program, or Code Page) 682 | $cw = 231; 683 | break; 684 | } 685 | } 686 | return $cw; 687 | } 688 | 689 | /** 690 | * Choose the minimum matrix size and return the max number of data codewords. 691 | * @param $numcw (int) Number of current codewords. 692 | * @return number of data codewords in matrix 693 | * @protected 694 | */ 695 | protected function getMaxDataCodewords($numcw) { 696 | foreach ($this->symbattr as $key => $matrix) { 697 | if ($matrix[11] >= $numcw) { 698 | return $matrix[11]; 699 | } 700 | } 701 | return 0; 702 | } 703 | 704 | /** 705 | * Get high level encoding using the minimum symbol data characters for ECC 200 706 | * @param $data (string) data to encode 707 | * @return array of codewords 708 | * @protected 709 | */ 710 | protected function getHighLevelEncoding($data) { 711 | // STEP A. Start in ASCII encodation. 712 | $enc = ENC_ASCII; // current encoding mode 713 | $pos = 0; // current position 714 | $cw = array(); // array of codewords to be returned 715 | $cw_num = 0; // number of data codewords 716 | $data_length = strlen($data); // number of chars 717 | while ($pos < $data_length) { 718 | // set last used encoding 719 | $this->last_enc = $enc; 720 | switch ($enc) { 721 | case ENC_ASCII: { // STEP B. While in ASCII encodation 722 | if (($data_length > 1) AND ($pos < ($data_length - 1)) AND ($this->isCharMode(ord($data[$pos]), ENC_ASCII_NUM) AND $this->isCharMode(ord($data[$pos + 1]), ENC_ASCII_NUM))) { 723 | // 1. If the next data sequence is at least 2 consecutive digits, encode the next two digits as a double digit in ASCII mode. 724 | $cw[] = (intval(substr($data, $pos, 2)) + 130); 725 | ++$cw_num; 726 | $pos += 2; 727 | } else { 728 | // 2. If the look-ahead test (starting at step J) indicates another mode, switch to that mode. 729 | $newenc = $this->lookAheadTest($data, $pos, $enc); 730 | if ($newenc != $enc) { 731 | // switch to new encoding 732 | $enc = $newenc; 733 | $cw[] = $this->getSwitchEncodingCodeword($enc); 734 | ++$cw_num; 735 | } else { 736 | // get new byte 737 | $chr = ord($data[$pos]); 738 | ++$pos; 739 | if ($this->isCharMode($chr, ENC_ASCII_EXT)) { 740 | // 3. If the next data character is extended ASCII (greater than 127) encode it in ASCII mode first using the Upper Shift (value 235) character. 741 | $cw[] = 235; 742 | $cw[] = ($chr - 127); 743 | $cw_num += 2; 744 | } else { 745 | // 4. Otherwise process the next data character in ASCII encodation. 746 | $cw[] = ($chr + 1); 747 | ++$cw_num; 748 | } 749 | } 750 | } 751 | break; 752 | } 753 | case ENC_C40 : // Upper-case alphanumeric 754 | case ENC_TXT : // Lower-case alphanumeric 755 | case ENC_X12 : { // ANSI X12 756 | $temp_cw = array(); 757 | $p = 0; 758 | $epos = $pos; 759 | // get charset ID 760 | $set_id = $this->chset_id[$enc]; 761 | // get basic charset for current encoding 762 | $charset = $this->chset[$set_id]; 763 | do { 764 | // 2. process the next character in C40 encodation. 765 | $chr = ord($data[$epos]); 766 | ++$epos; 767 | // check for extended character 768 | if ($chr & 0x80) { 769 | if ($enc == ENC_X12) { 770 | return false; 771 | } 772 | $chr = ($chr & 0x7f); 773 | $temp_cw[] = 1; // shift 2 774 | $temp_cw[] = 30; // upper shift 775 | $p += 2; 776 | } 777 | if (isset($charset[$chr])) { 778 | $temp_cw[] = $charset[$chr]; 779 | ++$p; 780 | } else { 781 | if (isset($this->chset['SH1'][$chr])) { 782 | $temp_cw[] = 0; // shift 1 783 | $shiftset = $this->chset['SH1']; 784 | } elseif (isset($chr, $this->chset['SH2'][$chr])) { 785 | $temp_cw[] = 1; // shift 2 786 | $shiftset = $this->chset['SH2']; 787 | } elseif (($enc == ENC_C40) AND isset($this->chset['S3C'][$chr])) { 788 | $temp_cw[] = 2; // shift 3 789 | $shiftset = $this->chset['S3C']; 790 | } elseif (($enc == ENC_TXT) AND isset($this->chset['S3T'][$chr])) { 791 | $temp_cw[] = 2; // shift 3 792 | $shiftset = $this->chset['S3T']; 793 | } else { 794 | return false; 795 | } 796 | $temp_cw[] = $shiftset[$chr]; 797 | $p += 2; 798 | } 799 | if ($p >= 3) { 800 | $c1 = array_shift($temp_cw); 801 | $c2 = array_shift($temp_cw); 802 | $c3 = array_shift($temp_cw); 803 | $p -= 3; 804 | $tmp = ((1600 * $c1) + (40 * $c2) + $c3 + 1); 805 | $cw[] = ($tmp >> 8); 806 | $cw[] = ($tmp % 256); 807 | $cw_num += 2; 808 | $pos = $epos; 809 | // 1. If the C40 encoding is at the point of starting a new double symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode. 810 | $newenc = $this->lookAheadTest($data, $pos, $enc); 811 | if ($newenc != $enc) { 812 | // switch to new encoding 813 | $enc = $newenc; 814 | if ($enc != ENC_ASCII) { 815 | // set unlatch character 816 | $cw[] = $this->getSwitchEncodingCodeword(ENC_ASCII); 817 | ++$cw_num; 818 | } 819 | $cw[] = $this->getSwitchEncodingCodeword($enc); 820 | ++$cw_num; 821 | $pos -= $p; 822 | $p = 0; 823 | break; 824 | } 825 | } 826 | } while (($p > 0) AND ($epos < $data_length)); 827 | // process last data (if any) 828 | if ($p > 0) { 829 | // get remaining number of data symbols 830 | $cwr = ($this->getMaxDataCodewords($cw_num) - $cw_num); 831 | if (($cwr == 1) AND ($p == 1)) { 832 | // d. If one symbol character remains and one C40 value (data character) remains to be encoded 833 | $c1 = array_shift($temp_cw); 834 | --$p; 835 | $cw[] = ($chr + 1); 836 | ++$cw_num; 837 | $pos = $epos; 838 | $enc = ENC_ASCII; 839 | $this->last_enc = $enc; 840 | } elseif (($cwr == 2) AND ($p == 1)) { 841 | // c. If two symbol characters remain and only one C40 value (data character) remains to be encoded 842 | $c1 = array_shift($temp_cw); 843 | --$p; 844 | $cw[] = 254; 845 | $cw[] = ($chr + 1); 846 | $cw_num += 2; 847 | $pos = $epos; 848 | $enc = ENC_ASCII; 849 | $this->last_enc = $enc; 850 | } elseif (($cwr == 2) AND ($p == 2)) { 851 | // b. If two symbol characters remain and two C40 values remain to be encoded 852 | $c1 = array_shift($temp_cw); 853 | $c2 = array_shift($temp_cw); 854 | $p -= 2; 855 | $tmp = ((1600 * $c1) + (40 * $c2) + 1); 856 | $cw[] = ($tmp >> 8); 857 | $cw[] = ($tmp % 256); 858 | $cw_num += 2; 859 | $pos = $epos; 860 | $enc = ENC_ASCII; 861 | $this->last_enc = $enc; 862 | } else { 863 | // switch to ASCII encoding 864 | if ($enc != ENC_ASCII) { 865 | $enc = ENC_ASCII; 866 | $this->last_enc = $enc; 867 | $cw[] = $this->getSwitchEncodingCodeword($enc); 868 | ++$cw_num; 869 | $pos = ($epos - $p); 870 | } 871 | } 872 | } 873 | break; 874 | } 875 | case ENC_EDF: { // F. While in EDIFACT (EDF) encodation 876 | // initialize temporary array with 0 length 877 | $temp_cw = array(); 878 | $epos = $pos; 879 | $field_length = 0; 880 | $newenc = $enc; 881 | do { 882 | // 2. process the next character in EDIFACT encodation. 883 | $chr = ord($data[$epos]); 884 | if ($this->isCharMode($chr, ENC_EDF)) { 885 | ++$epos; 886 | $temp_cw[] = $chr; 887 | ++$field_length; 888 | } 889 | if (($field_length == 4) OR ($epos == $data_length) OR !$this->isCharMode($chr, ENC_EDF)) { 890 | if (($epos == $data_length) AND ($field_length < 3)) { 891 | $enc = ENC_ASCII; 892 | $cw[] = $this->getSwitchEncodingCodeword($enc); 893 | ++$cw_num; 894 | break; 895 | } 896 | if ($field_length < 4) { 897 | // set unlatch character 898 | $temp_cw[] = 0x1f; 899 | ++$field_length; 900 | // fill empty characters 901 | for ($i = $field_length; $i < 4; ++$i) { 902 | $temp_cw[] = 0; 903 | } 904 | $enc = ENC_ASCII; 905 | $this->last_enc = $enc; 906 | } 907 | // encodes four data characters in three codewords 908 | $tcw = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4); 909 | if ($tcw > 0) { 910 | $cw[] = $tcw; 911 | $cw_num++; 912 | } 913 | $tcw= (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2); 914 | if ($tcw > 0) { 915 | $cw[] = $tcw; 916 | $cw_num++; 917 | } 918 | $tcw = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F); 919 | if ($tcw > 0) { 920 | $cw[] = $tcw; 921 | $cw_num++; 922 | } 923 | $temp_cw = array(); 924 | $pos = $epos; 925 | $field_length = 0; 926 | if ($enc == ENC_ASCII) { 927 | break; // exit from EDIFACT mode 928 | } 929 | } 930 | } while ($epos < $data_length); 931 | break; 932 | } 933 | case ENC_BASE256: { // G. While in Base 256 (B256) encodation 934 | // initialize temporary array with 0 length 935 | $temp_cw = array(); 936 | $field_length = 0; 937 | while (($pos < $data_length) AND ($field_length <= 1555)) { 938 | $newenc = $this->lookAheadTest($data, $pos, $enc); 939 | if ($newenc != $enc) { 940 | // 1. If the look-ahead test (starting at step J) indicates another mode, switch to that mode. 941 | $enc = $newenc; 942 | break; // exit from B256 mode 943 | } else { 944 | // 2. Otherwise, process the next character in Base 256 encodation. 945 | $chr = ord($data[$pos]); 946 | ++$pos; 947 | $temp_cw[] = $chr; 948 | ++$field_length; 949 | } 950 | } 951 | // set field length 952 | if ($field_length <= 249) { 953 | $cw[] = $this->get255StateCodeword($field_length, ($cw_num + 1)); 954 | ++$cw_num; 955 | } else { 956 | $cw[] = $this->get255StateCodeword((floor($field_length / 250) + 249), ($cw_num + 1)); 957 | $cw[] = $this->get255StateCodeword(($field_length % 250), ($cw_num + 2)); 958 | $cw_num += 2; 959 | } 960 | if (!empty($temp_cw)) { 961 | // add B256 field 962 | foreach ($temp_cw as $p => $cht) { 963 | $cw[] = $this->get255StateCodeword($cht, ($cw_num + $p + 1)); 964 | } 965 | } 966 | break; 967 | } 968 | } // end of switch enc 969 | } // end of while 970 | return $cw; 971 | } 972 | 973 | /** 974 | * Places "chr+bit" with appropriate wrapping within array[]. 975 | * (Annex F - ECC 200 symbol character placement) 976 | * @param $marr (array) Array of symbols. 977 | * @param $nrow (int) Number of rows. 978 | * @param $ncol (int) Number of columns. 979 | * @param $row (int) Row number. 980 | * @param $col (int) Column number. 981 | * @param $chr (int) Char byte. 982 | * @param $bit (int) Bit. 983 | * @return array 984 | * @protected 985 | */ 986 | protected function placeModule($marr, $nrow, $ncol, $row, $col, $chr, $bit) { 987 | if ($row < 0) { 988 | $row += $nrow; 989 | $col += (4 - (($nrow + 4) % 8)); 990 | } 991 | if ($col < 0) { 992 | $col += $ncol; 993 | $row += (4 - (($ncol + 4) % 8)); 994 | } 995 | $marr[(($row * $ncol) + $col)] = ((10 * $chr) + $bit); 996 | return $marr; 997 | } 998 | 999 | /** 1000 | * Places the 8 bits of a utah-shaped symbol character. 1001 | * (Annex F - ECC 200 symbol character placement) 1002 | * @param $marr (array) Array of symbols. 1003 | * @param $nrow (int) Number of rows. 1004 | * @param $ncol (int) Number of columns. 1005 | * @param $row (int) Row number. 1006 | * @param $col (int) Column number. 1007 | * @param $chr (int) Char byte. 1008 | * @return array 1009 | * @protected 1010 | */ 1011 | protected function placeUtah($marr, $nrow, $ncol, $row, $col, $chr) { 1012 | $marr = $this->placeModule($marr, $nrow, $ncol, $row-2, $col-2, $chr, 1); 1013 | $marr = $this->placeModule($marr, $nrow, $ncol, $row-2, $col-1, $chr, 2); 1014 | $marr = $this->placeModule($marr, $nrow, $ncol, $row-1, $col-2, $chr, 3); 1015 | $marr = $this->placeModule($marr, $nrow, $ncol, $row-1, $col-1, $chr, 4); 1016 | $marr = $this->placeModule($marr, $nrow, $ncol, $row-1, $col, $chr, 5); 1017 | $marr = $this->placeModule($marr, $nrow, $ncol, $row, $col-2, $chr, 6); 1018 | $marr = $this->placeModule($marr, $nrow, $ncol, $row, $col-1, $chr, 7); 1019 | $marr = $this->placeModule($marr, $nrow, $ncol, $row, $col, $chr, 8); 1020 | return $marr; 1021 | } 1022 | 1023 | /** 1024 | * Places the 8 bits of the first special corner case. 1025 | * (Annex F - ECC 200 symbol character placement) 1026 | * @param $marr (array) Array of symbols. 1027 | * @param $nrow (int) Number of rows. 1028 | * @param $ncol (int) Number of columns. 1029 | * @param $chr (int) Char byte. 1030 | * @return array 1031 | * @protected 1032 | */ 1033 | protected function placeCornerA($marr, $nrow, $ncol, $chr) { 1034 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, 0, $chr, 1); 1035 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, 1, $chr, 2); 1036 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, 2, $chr, 3); 1037 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-2, $chr, 4); 1038 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-1, $chr, 5); 1039 | $marr = $this->placeModule($marr, $nrow, $ncol, 1, $ncol-1, $chr, 6); 1040 | $marr = $this->placeModule($marr, $nrow, $ncol, 2, $ncol-1, $chr, 7); 1041 | $marr = $this->placeModule($marr, $nrow, $ncol, 3, $ncol-1, $chr, 8); 1042 | return $marr; 1043 | } 1044 | 1045 | /** 1046 | * Places the 8 bits of the second special corner case. 1047 | * (Annex F - ECC 200 symbol character placement) 1048 | * @param $marr (array) Array of symbols. 1049 | * @param $nrow (int) Number of rows. 1050 | * @param $ncol (int) Number of columns. 1051 | * @param $chr (int) Char byte. 1052 | * @return array 1053 | * @protected 1054 | */ 1055 | protected function placeCornerB($marr, $nrow, $ncol, $chr) { 1056 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-3, 0, $chr, 1); 1057 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-2, 0, $chr, 2); 1058 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, 0, $chr, 3); 1059 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-4, $chr, 4); 1060 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-3, $chr, 5); 1061 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-2, $chr, 6); 1062 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-1, $chr, 7); 1063 | $marr = $this->placeModule($marr, $nrow, $ncol, 1, $ncol-1, $chr, 8); 1064 | return $marr; 1065 | } 1066 | 1067 | /** 1068 | * Places the 8 bits of the third special corner case. 1069 | * (Annex F - ECC 200 symbol character placement) 1070 | * @param $marr (array) Array of symbols. 1071 | * @param $nrow (int) Number of rows. 1072 | * @param $ncol (int) Number of columns. 1073 | * @param $chr (int) Char byte. 1074 | * @return array 1075 | * @protected 1076 | */ 1077 | protected function placeCornerC($marr, $nrow, $ncol, $chr) { 1078 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-3, 0, $chr, 1); 1079 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-2, 0, $chr, 2); 1080 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, 0, $chr, 3); 1081 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-2, $chr, 4); 1082 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-1, $chr, 5); 1083 | $marr = $this->placeModule($marr, $nrow, $ncol, 1, $ncol-1, $chr, 6); 1084 | $marr = $this->placeModule($marr, $nrow, $ncol, 2, $ncol-1, $chr, 7); 1085 | $marr = $this->placeModule($marr, $nrow, $ncol, 3, $ncol-1, $chr, 8); 1086 | return $marr; 1087 | } 1088 | 1089 | /** 1090 | * Places the 8 bits of the fourth special corner case. 1091 | * (Annex F - ECC 200 symbol character placement) 1092 | * @param $marr (array) Array of symbols. 1093 | * @param $nrow (int) Number of rows. 1094 | * @param $ncol (int) Number of columns. 1095 | * @param $chr (int) Char byte. 1096 | * @return array 1097 | * @protected 1098 | */ 1099 | protected function placeCornerD($marr, $nrow, $ncol, $chr) { 1100 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, 0, $chr, 1); 1101 | $marr = $this->placeModule($marr, $nrow, $ncol, $nrow-1, $ncol-1, $chr, 2); 1102 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-3, $chr, 3); 1103 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-2, $chr, 4); 1104 | $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol-1, $chr, 5); 1105 | $marr = $this->placeModule($marr, $nrow, $ncol, 1, $ncol-3, $chr, 6); 1106 | $marr = $this->placeModule($marr, $nrow, $ncol, 1, $ncol-2, $chr, 7); 1107 | $marr = $this->placeModule($marr, $nrow, $ncol, 1, $ncol-1, $chr, 8); 1108 | return $marr; 1109 | } 1110 | 1111 | /** 1112 | * Build a placement map. 1113 | * (Annex F - ECC 200 symbol character placement) 1114 | * @param $nrow (int) Number of rows. 1115 | * @param $ncol (int) Number of columns. 1116 | * @return array 1117 | * @protected 1118 | */ 1119 | protected function getPlacementMap($nrow, $ncol) { 1120 | // initialize array with zeros 1121 | $marr = array_fill(0, ($nrow * $ncol), 0); 1122 | // set starting values 1123 | $chr = 1; 1124 | $row = 4; 1125 | $col = 0; 1126 | do { 1127 | // repeatedly first check for one of the special corner cases, then 1128 | if (($row == $nrow) AND ($col == 0)) { 1129 | $marr = $this->placeCornerA($marr, $nrow, $ncol, $chr); 1130 | ++$chr; 1131 | } 1132 | if (($row == ($nrow - 2)) AND ($col == 0) AND ($ncol % 4)) { 1133 | $marr = $this->placeCornerB($marr, $nrow, $ncol, $chr); 1134 | ++$chr; 1135 | } 1136 | if (($row == ($nrow - 2)) AND ($col == 0) AND (($ncol % 8) == 4)) { 1137 | $marr = $this->placeCornerC($marr, $nrow, $ncol, $chr); 1138 | ++$chr; 1139 | } 1140 | if (($row == ($nrow + 4)) AND ($col == 2) AND (!($ncol % 8))) { 1141 | $marr = $this->placeCornerD($marr, $nrow, $ncol, $chr); 1142 | ++$chr; 1143 | } 1144 | // sweep upward diagonally, inserting successive characters, 1145 | do { 1146 | if (($row < $nrow) AND ($col >= 0) AND (!$marr[(($row * $ncol) + $col)])) { 1147 | $marr = $this->placeUtah($marr, $nrow, $ncol, $row, $col, $chr); 1148 | ++$chr; 1149 | } 1150 | $row -= 2; 1151 | $col += 2; 1152 | } while (($row >= 0) AND ($col < $ncol)); 1153 | ++$row; 1154 | $col += 3; 1155 | // & then sweep downward diagonally, inserting successive characters,... 1156 | do { 1157 | if (($row >= 0) AND ($col < $ncol) AND (!$marr[(($row * $ncol) + $col)])) { 1158 | $marr = $this->placeUtah($marr, $nrow, $ncol, $row, $col, $chr); 1159 | ++$chr; 1160 | } 1161 | $row += 2; 1162 | $col -= 2; 1163 | } while (($row < $nrow) AND ($col >= 0)); 1164 | $row += 3; 1165 | ++$col; 1166 | // ... until the entire array is scanned 1167 | } while (($row < $nrow) OR ($col < $ncol)); 1168 | // lastly, if the lower righthand corner is untouched, fill in fixed pattern 1169 | if (!$marr[(($nrow * $ncol) - 1)]) { 1170 | $marr[(($nrow * $ncol) - 1)] = 1; 1171 | $marr[(($nrow * $ncol) - $ncol - 2)] = 1; 1172 | } 1173 | return $marr; 1174 | } 1175 | 1176 | } // end DataMatrix class 1177 | //============================================================+ 1178 | // END OF FILE 1179 | //============================================================+ 1180 | -------------------------------------------------------------------------------- /src/Milon/Barcode/PDF417.php: -------------------------------------------------------------------------------- 1 | . 29 | // 30 | // See LICENSE.TXT file for more information. 31 | // ------------------------------------------------------------------- 32 | // 33 | // DESCRIPTION : 34 | // 35 | // Class to create PDF417 barcode arrays for TCPDF class. 36 | // PDF417 (ISO/IEC 15438:2006) is a 2-dimensional stacked bar code created by Symbol Technologies in 1991. 37 | // It is one of the most popular 2D codes because of its ability to be read with slightly modified handheld laser or linear CCD scanners. 38 | // TECHNICAL DATA / FEATURES OF PDF417: 39 | // Encodable Character Set: All 128 ASCII Characters (including extended) 40 | // Code Type: Continuous, Multi-Row 41 | // Symbol Height: 3 - 90 Rows 42 | // Symbol Width: 90X - 583X 43 | // Bidirectional Decoding: Yes 44 | // Error Correction Characters: 2 - 512 45 | // Maximum Data Characters: 1850 text, 2710 digits, 1108 bytes 46 | // 47 | //============================================================+ 48 | 49 | /** 50 | * @file 51 | * Class to create PDF417 barcode arrays for TCPDF class. 52 | * PDF417 (ISO/IEC 15438:2006) is a 2-dimensional stacked bar code created by Symbol Technologies in 1991. 53 | * (requires PHP bcmath extension) 54 | * @package com.tecnick.tcpdf 55 | * @author Nicola Asuni 56 | * @version 1.0.005 57 | */ 58 | 59 | // definitions 60 | if (!defined('PDF417DEFS')) { 61 | 62 | /** 63 | * Indicate that definitions for this class are set 64 | */ 65 | define('PDF417DEFS', true); 66 | 67 | // ----------------------------------------------------- 68 | 69 | /** 70 | * Row height respect X dimension of single module 71 | */ 72 | define('ROWHEIGHT', 4); 73 | 74 | /** 75 | * Horizontal quiet zone in modules 76 | */ 77 | define('QUIETH', 2); 78 | 79 | /** 80 | * Vertical quiet zone in modules 81 | */ 82 | define('QUIETV', 2); 83 | 84 | } // end of definitions 85 | 86 | // #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# 87 | 88 | /** 89 | * @class PDF417 90 | * Class to create PDF417 barcode arrays for TCPDF class. 91 | * PDF417 (ISO/IEC 15438:2006) is a 2-dimensional stacked bar code created by Symbol Technologies in 1991. 92 | * @package com.tecnick.tcpdf 93 | * @author Nicola Asuni 94 | * @version 1.0.003 95 | */ 96 | class PDF417 { 97 | 98 | /** 99 | * Barcode array to be returned which is readable by TCPDF. 100 | * @protected 101 | */ 102 | protected $barcode_array = array(); 103 | 104 | /** 105 | * Start pattern. 106 | * @protected 107 | */ 108 | protected $start_pattern = '11111111010101000'; 109 | 110 | /** 111 | * Stop pattern. 112 | * @protected 113 | */ 114 | protected $stop_pattern = '111111101000101001'; 115 | 116 | /** 117 | * Array of text Compaction Sub-Modes (values 0xFB - 0xFF are used for submode changers). 118 | * @protected 119 | */ 120 | protected $textsubmodes = array( 121 | array(0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x20,0xFD,0xFE,0xFF), // Alpha 122 | array(0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x20,0xFD,0xFE,0xFF), // Lower 123 | array(0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x26,0x0d,0x09,0x2c,0x3a,0x23,0x2d,0x2e,0x24,0x2f,0x2b,0x25,0x2a,0x3d,0x5e,0xFB,0x20,0xFD,0xFE,0xFF), // Mixed 124 | array(0x3b,0x3c,0x3e,0x40,0x5b,0x5c,0x5d,0x5f,0x60,0x7e,0x21,0x0d,0x09,0x2c,0x3a,0x0a,0x2d,0x2e,0x24,0x2f,0x22,0x7c,0x2a,0x28,0x29,0x3f,0x7b,0x7d,0x27,0xFF) // Puntuaction 125 | ); 126 | 127 | /** 128 | * Array of switching codes for Text Compaction Sub-Modes. 129 | * @protected 130 | */ 131 | protected $textlatch = array( 132 | '01' => array(27), '02' => array(28), '03' => array(28,25), // 133 | '10' => array(28,28), '12' => array(28), '13' => array(28,25), // 134 | '20' => array(28), '21' => array(27), '23' => array(25), // 135 | '30' => array(29), '31' => array(29,27), '32' => array(29,28) // 136 | ); 137 | 138 | /** 139 | * Clusters of codewords (0, 3, 6)
    140 | * Values are hex equivalents of binary representation of bars (1 = bar, 0 = space).
    141 | * The codewords numbered from 900 to 928 have special meaning, some enable to switch between modes in order to optimise the code:
      142 | *
    • 900 : Switch to "Text" mode
    • 143 | *
    • 901 : Switch to "Byte" mode
    • 144 | *
    • 902 : Switch to "Numeric" mode
    • 145 | *
    • 903 - 912 : Reserved
    • 146 | *
    • 913 : Switch to "Octet" only for the next codeword
    • 147 | *
    • 914 - 920 : Reserved
    • 148 | *
    • 921 : Initialization
    • 149 | *
    • 922 : Terminator codeword for Macro PDF control block
    • 150 | *
    • 923 : Sequence tag to identify the beginning of optional fields in the Macro PDF control block
    • 151 | *
    • 924 : Switch to "Byte" mode (If the total number of byte is multiple of 6)
    • 152 | *
    • 925 : Identifier for a user defined Extended Channel Interpretation (ECI)
    • 153 | *
    • 926 : Identifier for a general purpose ECI format
    • 154 | *
    • 927 : Identifier for an ECI of a character set or code page
    • 155 | *
    • 928 : Macro marker codeword to indicate the beginning of a Macro PDF Control Block
    • 156 | *
    157 | * @protected 158 | */ 159 | protected $clusters = array( 160 | array( // cluster 0 ----------------------------------------------------------------------- 161 | 0x1d5c0,0x1eaf0,0x1f57c,0x1d4e0,0x1ea78,0x1f53e,0x1a8c0,0x1d470,0x1a860,0x15040, // 10 162 | 0x1a830,0x15020,0x1adc0,0x1d6f0,0x1eb7c,0x1ace0,0x1d678,0x1eb3e,0x158c0,0x1ac70, // 20 163 | 0x15860,0x15dc0,0x1aef0,0x1d77c,0x15ce0,0x1ae78,0x1d73e,0x15c70,0x1ae3c,0x15ef0, // 30 164 | 0x1af7c,0x15e78,0x1af3e,0x15f7c,0x1f5fa,0x1d2e0,0x1e978,0x1f4be,0x1a4c0,0x1d270, // 40 165 | 0x1e93c,0x1a460,0x1d238,0x14840,0x1a430,0x1d21c,0x14820,0x1a418,0x14810,0x1a6e0, // 50 166 | 0x1d378,0x1e9be,0x14cc0,0x1a670,0x1d33c,0x14c60,0x1a638,0x1d31e,0x14c30,0x1a61c, // 60 167 | 0x14ee0,0x1a778,0x1d3be,0x14e70,0x1a73c,0x14e38,0x1a71e,0x14f78,0x1a7be,0x14f3c, // 70 168 | 0x14f1e,0x1a2c0,0x1d170,0x1e8bc,0x1a260,0x1d138,0x1e89e,0x14440,0x1a230,0x1d11c, // 80 169 | 0x14420,0x1a218,0x14410,0x14408,0x146c0,0x1a370,0x1d1bc,0x14660,0x1a338,0x1d19e, // 90 170 | 0x14630,0x1a31c,0x14618,0x1460c,0x14770,0x1a3bc,0x14738,0x1a39e,0x1471c,0x147bc, // 100 171 | 0x1a160,0x1d0b8,0x1e85e,0x14240,0x1a130,0x1d09c,0x14220,0x1a118,0x1d08e,0x14210, // 110 172 | 0x1a10c,0x14208,0x1a106,0x14360,0x1a1b8,0x1d0de,0x14330,0x1a19c,0x14318,0x1a18e, // 120 173 | 0x1430c,0x14306,0x1a1de,0x1438e,0x14140,0x1a0b0,0x1d05c,0x14120,0x1a098,0x1d04e, // 130 174 | 0x14110,0x1a08c,0x14108,0x1a086,0x14104,0x141b0,0x14198,0x1418c,0x140a0,0x1d02e, // 140 175 | 0x1a04c,0x1a046,0x14082,0x1cae0,0x1e578,0x1f2be,0x194c0,0x1ca70,0x1e53c,0x19460, // 150 176 | 0x1ca38,0x1e51e,0x12840,0x19430,0x12820,0x196e0,0x1cb78,0x1e5be,0x12cc0,0x19670, // 160 177 | 0x1cb3c,0x12c60,0x19638,0x12c30,0x12c18,0x12ee0,0x19778,0x1cbbe,0x12e70,0x1973c, // 170 178 | 0x12e38,0x12e1c,0x12f78,0x197be,0x12f3c,0x12fbe,0x1dac0,0x1ed70,0x1f6bc,0x1da60, // 180 179 | 0x1ed38,0x1f69e,0x1b440,0x1da30,0x1ed1c,0x1b420,0x1da18,0x1ed0e,0x1b410,0x1da0c, // 190 180 | 0x192c0,0x1c970,0x1e4bc,0x1b6c0,0x19260,0x1c938,0x1e49e,0x1b660,0x1db38,0x1ed9e, // 200 181 | 0x16c40,0x12420,0x19218,0x1c90e,0x16c20,0x1b618,0x16c10,0x126c0,0x19370,0x1c9bc, // 210 182 | 0x16ec0,0x12660,0x19338,0x1c99e,0x16e60,0x1b738,0x1db9e,0x16e30,0x12618,0x16e18, // 220 183 | 0x12770,0x193bc,0x16f70,0x12738,0x1939e,0x16f38,0x1b79e,0x16f1c,0x127bc,0x16fbc, // 230 184 | 0x1279e,0x16f9e,0x1d960,0x1ecb8,0x1f65e,0x1b240,0x1d930,0x1ec9c,0x1b220,0x1d918, // 240 185 | 0x1ec8e,0x1b210,0x1d90c,0x1b208,0x1b204,0x19160,0x1c8b8,0x1e45e,0x1b360,0x19130, // 250 186 | 0x1c89c,0x16640,0x12220,0x1d99c,0x1c88e,0x16620,0x12210,0x1910c,0x16610,0x1b30c, // 260 187 | 0x19106,0x12204,0x12360,0x191b8,0x1c8de,0x16760,0x12330,0x1919c,0x16730,0x1b39c, // 270 188 | 0x1918e,0x16718,0x1230c,0x12306,0x123b8,0x191de,0x167b8,0x1239c,0x1679c,0x1238e, // 280 189 | 0x1678e,0x167de,0x1b140,0x1d8b0,0x1ec5c,0x1b120,0x1d898,0x1ec4e,0x1b110,0x1d88c, // 290 190 | 0x1b108,0x1d886,0x1b104,0x1b102,0x12140,0x190b0,0x1c85c,0x16340,0x12120,0x19098, // 300 191 | 0x1c84e,0x16320,0x1b198,0x1d8ce,0x16310,0x12108,0x19086,0x16308,0x1b186,0x16304, // 310 192 | 0x121b0,0x190dc,0x163b0,0x12198,0x190ce,0x16398,0x1b1ce,0x1638c,0x12186,0x16386, // 320 193 | 0x163dc,0x163ce,0x1b0a0,0x1d858,0x1ec2e,0x1b090,0x1d84c,0x1b088,0x1d846,0x1b084, // 330 194 | 0x1b082,0x120a0,0x19058,0x1c82e,0x161a0,0x12090,0x1904c,0x16190,0x1b0cc,0x19046, // 340 195 | 0x16188,0x12084,0x16184,0x12082,0x120d8,0x161d8,0x161cc,0x161c6,0x1d82c,0x1d826, // 350 196 | 0x1b042,0x1902c,0x12048,0x160c8,0x160c4,0x160c2,0x18ac0,0x1c570,0x1e2bc,0x18a60, // 360 197 | 0x1c538,0x11440,0x18a30,0x1c51c,0x11420,0x18a18,0x11410,0x11408,0x116c0,0x18b70, // 370 198 | 0x1c5bc,0x11660,0x18b38,0x1c59e,0x11630,0x18b1c,0x11618,0x1160c,0x11770,0x18bbc, // 380 199 | 0x11738,0x18b9e,0x1171c,0x117bc,0x1179e,0x1cd60,0x1e6b8,0x1f35e,0x19a40,0x1cd30, // 390 200 | 0x1e69c,0x19a20,0x1cd18,0x1e68e,0x19a10,0x1cd0c,0x19a08,0x1cd06,0x18960,0x1c4b8, // 400 201 | 0x1e25e,0x19b60,0x18930,0x1c49c,0x13640,0x11220,0x1cd9c,0x1c48e,0x13620,0x19b18, // 410 202 | 0x1890c,0x13610,0x11208,0x13608,0x11360,0x189b8,0x1c4de,0x13760,0x11330,0x1cdde, // 420 203 | 0x13730,0x19b9c,0x1898e,0x13718,0x1130c,0x1370c,0x113b8,0x189de,0x137b8,0x1139c, // 430 204 | 0x1379c,0x1138e,0x113de,0x137de,0x1dd40,0x1eeb0,0x1f75c,0x1dd20,0x1ee98,0x1f74e, // 440 205 | 0x1dd10,0x1ee8c,0x1dd08,0x1ee86,0x1dd04,0x19940,0x1ccb0,0x1e65c,0x1bb40,0x19920, // 450 206 | 0x1eedc,0x1e64e,0x1bb20,0x1dd98,0x1eece,0x1bb10,0x19908,0x1cc86,0x1bb08,0x1dd86, // 460 207 | 0x19902,0x11140,0x188b0,0x1c45c,0x13340,0x11120,0x18898,0x1c44e,0x17740,0x13320, // 470 208 | 0x19998,0x1ccce,0x17720,0x1bb98,0x1ddce,0x18886,0x17710,0x13308,0x19986,0x17708, // 480 209 | 0x11102,0x111b0,0x188dc,0x133b0,0x11198,0x188ce,0x177b0,0x13398,0x199ce,0x17798, // 490 210 | 0x1bbce,0x11186,0x13386,0x111dc,0x133dc,0x111ce,0x177dc,0x133ce,0x1dca0,0x1ee58, // 500 211 | 0x1f72e,0x1dc90,0x1ee4c,0x1dc88,0x1ee46,0x1dc84,0x1dc82,0x198a0,0x1cc58,0x1e62e, // 510 212 | 0x1b9a0,0x19890,0x1ee6e,0x1b990,0x1dccc,0x1cc46,0x1b988,0x19884,0x1b984,0x19882, // 520 213 | 0x1b982,0x110a0,0x18858,0x1c42e,0x131a0,0x11090,0x1884c,0x173a0,0x13190,0x198cc, // 530 214 | 0x18846,0x17390,0x1b9cc,0x11084,0x17388,0x13184,0x11082,0x13182,0x110d8,0x1886e, // 540 215 | 0x131d8,0x110cc,0x173d8,0x131cc,0x110c6,0x173cc,0x131c6,0x110ee,0x173ee,0x1dc50, // 550 216 | 0x1ee2c,0x1dc48,0x1ee26,0x1dc44,0x1dc42,0x19850,0x1cc2c,0x1b8d0,0x19848,0x1cc26, // 560 217 | 0x1b8c8,0x1dc66,0x1b8c4,0x19842,0x1b8c2,0x11050,0x1882c,0x130d0,0x11048,0x18826, // 570 218 | 0x171d0,0x130c8,0x19866,0x171c8,0x1b8e6,0x11042,0x171c4,0x130c2,0x171c2,0x130ec, // 580 219 | 0x171ec,0x171e6,0x1ee16,0x1dc22,0x1cc16,0x19824,0x19822,0x11028,0x13068,0x170e8, // 590 220 | 0x11022,0x13062,0x18560,0x10a40,0x18530,0x10a20,0x18518,0x1c28e,0x10a10,0x1850c, // 600 221 | 0x10a08,0x18506,0x10b60,0x185b8,0x1c2de,0x10b30,0x1859c,0x10b18,0x1858e,0x10b0c, // 610 222 | 0x10b06,0x10bb8,0x185de,0x10b9c,0x10b8e,0x10bde,0x18d40,0x1c6b0,0x1e35c,0x18d20, // 620 223 | 0x1c698,0x18d10,0x1c68c,0x18d08,0x1c686,0x18d04,0x10940,0x184b0,0x1c25c,0x11b40, // 630 224 | 0x10920,0x1c6dc,0x1c24e,0x11b20,0x18d98,0x1c6ce,0x11b10,0x10908,0x18486,0x11b08, // 640 225 | 0x18d86,0x10902,0x109b0,0x184dc,0x11bb0,0x10998,0x184ce,0x11b98,0x18dce,0x11b8c, // 650 226 | 0x10986,0x109dc,0x11bdc,0x109ce,0x11bce,0x1cea0,0x1e758,0x1f3ae,0x1ce90,0x1e74c, // 660 227 | 0x1ce88,0x1e746,0x1ce84,0x1ce82,0x18ca0,0x1c658,0x19da0,0x18c90,0x1c64c,0x19d90, // 670 228 | 0x1cecc,0x1c646,0x19d88,0x18c84,0x19d84,0x18c82,0x19d82,0x108a0,0x18458,0x119a0, // 680 229 | 0x10890,0x1c66e,0x13ba0,0x11990,0x18ccc,0x18446,0x13b90,0x19dcc,0x10884,0x13b88, // 690 230 | 0x11984,0x10882,0x11982,0x108d8,0x1846e,0x119d8,0x108cc,0x13bd8,0x119cc,0x108c6, // 700 231 | 0x13bcc,0x119c6,0x108ee,0x119ee,0x13bee,0x1ef50,0x1f7ac,0x1ef48,0x1f7a6,0x1ef44, // 710 232 | 0x1ef42,0x1ce50,0x1e72c,0x1ded0,0x1ef6c,0x1e726,0x1dec8,0x1ef66,0x1dec4,0x1ce42, // 720 233 | 0x1dec2,0x18c50,0x1c62c,0x19cd0,0x18c48,0x1c626,0x1bdd0,0x19cc8,0x1ce66,0x1bdc8, // 730 234 | 0x1dee6,0x18c42,0x1bdc4,0x19cc2,0x1bdc2,0x10850,0x1842c,0x118d0,0x10848,0x18426, // 740 235 | 0x139d0,0x118c8,0x18c66,0x17bd0,0x139c8,0x19ce6,0x10842,0x17bc8,0x1bde6,0x118c2, // 750 236 | 0x17bc4,0x1086c,0x118ec,0x10866,0x139ec,0x118e6,0x17bec,0x139e6,0x17be6,0x1ef28, // 760 237 | 0x1f796,0x1ef24,0x1ef22,0x1ce28,0x1e716,0x1de68,0x1ef36,0x1de64,0x1ce22,0x1de62, // 770 238 | 0x18c28,0x1c616,0x19c68,0x18c24,0x1bce8,0x19c64,0x18c22,0x1bce4,0x19c62,0x1bce2, // 780 239 | 0x10828,0x18416,0x11868,0x18c36,0x138e8,0x11864,0x10822,0x179e8,0x138e4,0x11862, // 790 240 | 0x179e4,0x138e2,0x179e2,0x11876,0x179f6,0x1ef12,0x1de34,0x1de32,0x19c34,0x1bc74, // 800 241 | 0x1bc72,0x11834,0x13874,0x178f4,0x178f2,0x10540,0x10520,0x18298,0x10510,0x10508, // 810 242 | 0x10504,0x105b0,0x10598,0x1058c,0x10586,0x105dc,0x105ce,0x186a0,0x18690,0x1c34c, // 820 243 | 0x18688,0x1c346,0x18684,0x18682,0x104a0,0x18258,0x10da0,0x186d8,0x1824c,0x10d90, // 830 244 | 0x186cc,0x10d88,0x186c6,0x10d84,0x10482,0x10d82,0x104d8,0x1826e,0x10dd8,0x186ee, // 840 245 | 0x10dcc,0x104c6,0x10dc6,0x104ee,0x10dee,0x1c750,0x1c748,0x1c744,0x1c742,0x18650, // 850 246 | 0x18ed0,0x1c76c,0x1c326,0x18ec8,0x1c766,0x18ec4,0x18642,0x18ec2,0x10450,0x10cd0, // 860 247 | 0x10448,0x18226,0x11dd0,0x10cc8,0x10444,0x11dc8,0x10cc4,0x10442,0x11dc4,0x10cc2, // 870 248 | 0x1046c,0x10cec,0x10466,0x11dec,0x10ce6,0x11de6,0x1e7a8,0x1e7a4,0x1e7a2,0x1c728, // 880 249 | 0x1cf68,0x1e7b6,0x1cf64,0x1c722,0x1cf62,0x18628,0x1c316,0x18e68,0x1c736,0x19ee8, // 890 250 | 0x18e64,0x18622,0x19ee4,0x18e62,0x19ee2,0x10428,0x18216,0x10c68,0x18636,0x11ce8, // 900 251 | 0x10c64,0x10422,0x13de8,0x11ce4,0x10c62,0x13de4,0x11ce2,0x10436,0x10c76,0x11cf6, // 910 252 | 0x13df6,0x1f7d4,0x1f7d2,0x1e794,0x1efb4,0x1e792,0x1efb2,0x1c714,0x1cf34,0x1c712, // 920 253 | 0x1df74,0x1cf32,0x1df72,0x18614,0x18e34,0x18612,0x19e74,0x18e32,0x1bef4), // 929 254 | array( // cluster 3 ----------------------------------------------------------------------- 255 | 0x1f560,0x1fab8,0x1ea40,0x1f530,0x1fa9c,0x1ea20,0x1f518,0x1fa8e,0x1ea10,0x1f50c, // 10 256 | 0x1ea08,0x1f506,0x1ea04,0x1eb60,0x1f5b8,0x1fade,0x1d640,0x1eb30,0x1f59c,0x1d620, // 20 257 | 0x1eb18,0x1f58e,0x1d610,0x1eb0c,0x1d608,0x1eb06,0x1d604,0x1d760,0x1ebb8,0x1f5de, // 30 258 | 0x1ae40,0x1d730,0x1eb9c,0x1ae20,0x1d718,0x1eb8e,0x1ae10,0x1d70c,0x1ae08,0x1d706, // 40 259 | 0x1ae04,0x1af60,0x1d7b8,0x1ebde,0x15e40,0x1af30,0x1d79c,0x15e20,0x1af18,0x1d78e, // 50 260 | 0x15e10,0x1af0c,0x15e08,0x1af06,0x15f60,0x1afb8,0x1d7de,0x15f30,0x1af9c,0x15f18, // 60 261 | 0x1af8e,0x15f0c,0x15fb8,0x1afde,0x15f9c,0x15f8e,0x1e940,0x1f4b0,0x1fa5c,0x1e920, // 70 262 | 0x1f498,0x1fa4e,0x1e910,0x1f48c,0x1e908,0x1f486,0x1e904,0x1e902,0x1d340,0x1e9b0, // 80 263 | 0x1f4dc,0x1d320,0x1e998,0x1f4ce,0x1d310,0x1e98c,0x1d308,0x1e986,0x1d304,0x1d302, // 90 264 | 0x1a740,0x1d3b0,0x1e9dc,0x1a720,0x1d398,0x1e9ce,0x1a710,0x1d38c,0x1a708,0x1d386, // 100 265 | 0x1a704,0x1a702,0x14f40,0x1a7b0,0x1d3dc,0x14f20,0x1a798,0x1d3ce,0x14f10,0x1a78c, // 110 266 | 0x14f08,0x1a786,0x14f04,0x14fb0,0x1a7dc,0x14f98,0x1a7ce,0x14f8c,0x14f86,0x14fdc, // 120 267 | 0x14fce,0x1e8a0,0x1f458,0x1fa2e,0x1e890,0x1f44c,0x1e888,0x1f446,0x1e884,0x1e882, // 130 268 | 0x1d1a0,0x1e8d8,0x1f46e,0x1d190,0x1e8cc,0x1d188,0x1e8c6,0x1d184,0x1d182,0x1a3a0, // 140 269 | 0x1d1d8,0x1e8ee,0x1a390,0x1d1cc,0x1a388,0x1d1c6,0x1a384,0x1a382,0x147a0,0x1a3d8, // 150 270 | 0x1d1ee,0x14790,0x1a3cc,0x14788,0x1a3c6,0x14784,0x14782,0x147d8,0x1a3ee,0x147cc, // 160 271 | 0x147c6,0x147ee,0x1e850,0x1f42c,0x1e848,0x1f426,0x1e844,0x1e842,0x1d0d0,0x1e86c, // 170 272 | 0x1d0c8,0x1e866,0x1d0c4,0x1d0c2,0x1a1d0,0x1d0ec,0x1a1c8,0x1d0e6,0x1a1c4,0x1a1c2, // 180 273 | 0x143d0,0x1a1ec,0x143c8,0x1a1e6,0x143c4,0x143c2,0x143ec,0x143e6,0x1e828,0x1f416, // 190 274 | 0x1e824,0x1e822,0x1d068,0x1e836,0x1d064,0x1d062,0x1a0e8,0x1d076,0x1a0e4,0x1a0e2, // 200 275 | 0x141e8,0x1a0f6,0x141e4,0x141e2,0x1e814,0x1e812,0x1d034,0x1d032,0x1a074,0x1a072, // 210 276 | 0x1e540,0x1f2b0,0x1f95c,0x1e520,0x1f298,0x1f94e,0x1e510,0x1f28c,0x1e508,0x1f286, // 220 277 | 0x1e504,0x1e502,0x1cb40,0x1e5b0,0x1f2dc,0x1cb20,0x1e598,0x1f2ce,0x1cb10,0x1e58c, // 230 278 | 0x1cb08,0x1e586,0x1cb04,0x1cb02,0x19740,0x1cbb0,0x1e5dc,0x19720,0x1cb98,0x1e5ce, // 240 279 | 0x19710,0x1cb8c,0x19708,0x1cb86,0x19704,0x19702,0x12f40,0x197b0,0x1cbdc,0x12f20, // 250 280 | 0x19798,0x1cbce,0x12f10,0x1978c,0x12f08,0x19786,0x12f04,0x12fb0,0x197dc,0x12f98, // 260 281 | 0x197ce,0x12f8c,0x12f86,0x12fdc,0x12fce,0x1f6a0,0x1fb58,0x16bf0,0x1f690,0x1fb4c, // 270 282 | 0x169f8,0x1f688,0x1fb46,0x168fc,0x1f684,0x1f682,0x1e4a0,0x1f258,0x1f92e,0x1eda0, // 280 283 | 0x1e490,0x1fb6e,0x1ed90,0x1f6cc,0x1f246,0x1ed88,0x1e484,0x1ed84,0x1e482,0x1ed82, // 290 284 | 0x1c9a0,0x1e4d8,0x1f26e,0x1dba0,0x1c990,0x1e4cc,0x1db90,0x1edcc,0x1e4c6,0x1db88, // 300 285 | 0x1c984,0x1db84,0x1c982,0x1db82,0x193a0,0x1c9d8,0x1e4ee,0x1b7a0,0x19390,0x1c9cc, // 310 286 | 0x1b790,0x1dbcc,0x1c9c6,0x1b788,0x19384,0x1b784,0x19382,0x1b782,0x127a0,0x193d8, // 320 287 | 0x1c9ee,0x16fa0,0x12790,0x193cc,0x16f90,0x1b7cc,0x193c6,0x16f88,0x12784,0x16f84, // 330 288 | 0x12782,0x127d8,0x193ee,0x16fd8,0x127cc,0x16fcc,0x127c6,0x16fc6,0x127ee,0x1f650, // 340 289 | 0x1fb2c,0x165f8,0x1f648,0x1fb26,0x164fc,0x1f644,0x1647e,0x1f642,0x1e450,0x1f22c, // 350 290 | 0x1ecd0,0x1e448,0x1f226,0x1ecc8,0x1f666,0x1ecc4,0x1e442,0x1ecc2,0x1c8d0,0x1e46c, // 360 291 | 0x1d9d0,0x1c8c8,0x1e466,0x1d9c8,0x1ece6,0x1d9c4,0x1c8c2,0x1d9c2,0x191d0,0x1c8ec, // 370 292 | 0x1b3d0,0x191c8,0x1c8e6,0x1b3c8,0x1d9e6,0x1b3c4,0x191c2,0x1b3c2,0x123d0,0x191ec, // 380 293 | 0x167d0,0x123c8,0x191e6,0x167c8,0x1b3e6,0x167c4,0x123c2,0x167c2,0x123ec,0x167ec, // 390 294 | 0x123e6,0x167e6,0x1f628,0x1fb16,0x162fc,0x1f624,0x1627e,0x1f622,0x1e428,0x1f216, // 400 295 | 0x1ec68,0x1f636,0x1ec64,0x1e422,0x1ec62,0x1c868,0x1e436,0x1d8e8,0x1c864,0x1d8e4, // 410 296 | 0x1c862,0x1d8e2,0x190e8,0x1c876,0x1b1e8,0x1d8f6,0x1b1e4,0x190e2,0x1b1e2,0x121e8, // 420 297 | 0x190f6,0x163e8,0x121e4,0x163e4,0x121e2,0x163e2,0x121f6,0x163f6,0x1f614,0x1617e, // 430 298 | 0x1f612,0x1e414,0x1ec34,0x1e412,0x1ec32,0x1c834,0x1d874,0x1c832,0x1d872,0x19074, // 440 299 | 0x1b0f4,0x19072,0x1b0f2,0x120f4,0x161f4,0x120f2,0x161f2,0x1f60a,0x1e40a,0x1ec1a, // 450 300 | 0x1c81a,0x1d83a,0x1903a,0x1b07a,0x1e2a0,0x1f158,0x1f8ae,0x1e290,0x1f14c,0x1e288, // 460 301 | 0x1f146,0x1e284,0x1e282,0x1c5a0,0x1e2d8,0x1f16e,0x1c590,0x1e2cc,0x1c588,0x1e2c6, // 470 302 | 0x1c584,0x1c582,0x18ba0,0x1c5d8,0x1e2ee,0x18b90,0x1c5cc,0x18b88,0x1c5c6,0x18b84, // 480 303 | 0x18b82,0x117a0,0x18bd8,0x1c5ee,0x11790,0x18bcc,0x11788,0x18bc6,0x11784,0x11782, // 490 304 | 0x117d8,0x18bee,0x117cc,0x117c6,0x117ee,0x1f350,0x1f9ac,0x135f8,0x1f348,0x1f9a6, // 500 305 | 0x134fc,0x1f344,0x1347e,0x1f342,0x1e250,0x1f12c,0x1e6d0,0x1e248,0x1f126,0x1e6c8, // 510 306 | 0x1f366,0x1e6c4,0x1e242,0x1e6c2,0x1c4d0,0x1e26c,0x1cdd0,0x1c4c8,0x1e266,0x1cdc8, // 520 307 | 0x1e6e6,0x1cdc4,0x1c4c2,0x1cdc2,0x189d0,0x1c4ec,0x19bd0,0x189c8,0x1c4e6,0x19bc8, // 530 308 | 0x1cde6,0x19bc4,0x189c2,0x19bc2,0x113d0,0x189ec,0x137d0,0x113c8,0x189e6,0x137c8, // 540 309 | 0x19be6,0x137c4,0x113c2,0x137c2,0x113ec,0x137ec,0x113e6,0x137e6,0x1fba8,0x175f0, // 550 310 | 0x1bafc,0x1fba4,0x174f8,0x1ba7e,0x1fba2,0x1747c,0x1743e,0x1f328,0x1f996,0x132fc, // 560 311 | 0x1f768,0x1fbb6,0x176fc,0x1327e,0x1f764,0x1f322,0x1767e,0x1f762,0x1e228,0x1f116, // 570 312 | 0x1e668,0x1e224,0x1eee8,0x1f776,0x1e222,0x1eee4,0x1e662,0x1eee2,0x1c468,0x1e236, // 580 313 | 0x1cce8,0x1c464,0x1dde8,0x1cce4,0x1c462,0x1dde4,0x1cce2,0x1dde2,0x188e8,0x1c476, // 590 314 | 0x199e8,0x188e4,0x1bbe8,0x199e4,0x188e2,0x1bbe4,0x199e2,0x1bbe2,0x111e8,0x188f6, // 600 315 | 0x133e8,0x111e4,0x177e8,0x133e4,0x111e2,0x177e4,0x133e2,0x177e2,0x111f6,0x133f6, // 610 316 | 0x1fb94,0x172f8,0x1b97e,0x1fb92,0x1727c,0x1723e,0x1f314,0x1317e,0x1f734,0x1f312, // 620 317 | 0x1737e,0x1f732,0x1e214,0x1e634,0x1e212,0x1ee74,0x1e632,0x1ee72,0x1c434,0x1cc74, // 630 318 | 0x1c432,0x1dcf4,0x1cc72,0x1dcf2,0x18874,0x198f4,0x18872,0x1b9f4,0x198f2,0x1b9f2, // 640 319 | 0x110f4,0x131f4,0x110f2,0x173f4,0x131f2,0x173f2,0x1fb8a,0x1717c,0x1713e,0x1f30a, // 650 320 | 0x1f71a,0x1e20a,0x1e61a,0x1ee3a,0x1c41a,0x1cc3a,0x1dc7a,0x1883a,0x1987a,0x1b8fa, // 660 321 | 0x1107a,0x130fa,0x171fa,0x170be,0x1e150,0x1f0ac,0x1e148,0x1f0a6,0x1e144,0x1e142, // 670 322 | 0x1c2d0,0x1e16c,0x1c2c8,0x1e166,0x1c2c4,0x1c2c2,0x185d0,0x1c2ec,0x185c8,0x1c2e6, // 680 323 | 0x185c4,0x185c2,0x10bd0,0x185ec,0x10bc8,0x185e6,0x10bc4,0x10bc2,0x10bec,0x10be6, // 690 324 | 0x1f1a8,0x1f8d6,0x11afc,0x1f1a4,0x11a7e,0x1f1a2,0x1e128,0x1f096,0x1e368,0x1e124, // 700 325 | 0x1e364,0x1e122,0x1e362,0x1c268,0x1e136,0x1c6e8,0x1c264,0x1c6e4,0x1c262,0x1c6e2, // 710 326 | 0x184e8,0x1c276,0x18de8,0x184e4,0x18de4,0x184e2,0x18de2,0x109e8,0x184f6,0x11be8, // 720 327 | 0x109e4,0x11be4,0x109e2,0x11be2,0x109f6,0x11bf6,0x1f9d4,0x13af8,0x19d7e,0x1f9d2, // 730 328 | 0x13a7c,0x13a3e,0x1f194,0x1197e,0x1f3b4,0x1f192,0x13b7e,0x1f3b2,0x1e114,0x1e334, // 740 329 | 0x1e112,0x1e774,0x1e332,0x1e772,0x1c234,0x1c674,0x1c232,0x1cef4,0x1c672,0x1cef2, // 750 330 | 0x18474,0x18cf4,0x18472,0x19df4,0x18cf2,0x19df2,0x108f4,0x119f4,0x108f2,0x13bf4, // 760 331 | 0x119f2,0x13bf2,0x17af0,0x1bd7c,0x17a78,0x1bd3e,0x17a3c,0x17a1e,0x1f9ca,0x1397c, // 770 332 | 0x1fbda,0x17b7c,0x1393e,0x17b3e,0x1f18a,0x1f39a,0x1f7ba,0x1e10a,0x1e31a,0x1e73a, // 780 333 | 0x1ef7a,0x1c21a,0x1c63a,0x1ce7a,0x1defa,0x1843a,0x18c7a,0x19cfa,0x1bdfa,0x1087a, // 790 334 | 0x118fa,0x139fa,0x17978,0x1bcbe,0x1793c,0x1791e,0x138be,0x179be,0x178bc,0x1789e, // 800 335 | 0x1785e,0x1e0a8,0x1e0a4,0x1e0a2,0x1c168,0x1e0b6,0x1c164,0x1c162,0x182e8,0x1c176, // 810 336 | 0x182e4,0x182e2,0x105e8,0x182f6,0x105e4,0x105e2,0x105f6,0x1f0d4,0x10d7e,0x1f0d2, // 820 337 | 0x1e094,0x1e1b4,0x1e092,0x1e1b2,0x1c134,0x1c374,0x1c132,0x1c372,0x18274,0x186f4, // 830 338 | 0x18272,0x186f2,0x104f4,0x10df4,0x104f2,0x10df2,0x1f8ea,0x11d7c,0x11d3e,0x1f0ca, // 840 339 | 0x1f1da,0x1e08a,0x1e19a,0x1e3ba,0x1c11a,0x1c33a,0x1c77a,0x1823a,0x1867a,0x18efa, // 850 340 | 0x1047a,0x10cfa,0x11dfa,0x13d78,0x19ebe,0x13d3c,0x13d1e,0x11cbe,0x13dbe,0x17d70, // 860 341 | 0x1bebc,0x17d38,0x1be9e,0x17d1c,0x17d0e,0x13cbc,0x17dbc,0x13c9e,0x17d9e,0x17cb8, // 870 342 | 0x1be5e,0x17c9c,0x17c8e,0x13c5e,0x17cde,0x17c5c,0x17c4e,0x17c2e,0x1c0b4,0x1c0b2, // 880 343 | 0x18174,0x18172,0x102f4,0x102f2,0x1e0da,0x1c09a,0x1c1ba,0x1813a,0x1837a,0x1027a, // 890 344 | 0x106fa,0x10ebe,0x11ebc,0x11e9e,0x13eb8,0x19f5e,0x13e9c,0x13e8e,0x11e5e,0x13ede, // 900 345 | 0x17eb0,0x1bf5c,0x17e98,0x1bf4e,0x17e8c,0x17e86,0x13e5c,0x17edc,0x13e4e,0x17ece, // 910 346 | 0x17e58,0x1bf2e,0x17e4c,0x17e46,0x13e2e,0x17e6e,0x17e2c,0x17e26,0x10f5e,0x11f5c, // 920 347 | 0x11f4e,0x13f58,0x19fae,0x13f4c,0x13f46,0x11f2e,0x13f6e,0x13f2c,0x13f26), // 929 348 | array( // cluster 6 ----------------------------------------------------------------------- 349 | 0x1abe0,0x1d5f8,0x153c0,0x1a9f0,0x1d4fc,0x151e0,0x1a8f8,0x1d47e,0x150f0,0x1a87c, // 10 350 | 0x15078,0x1fad0,0x15be0,0x1adf8,0x1fac8,0x159f0,0x1acfc,0x1fac4,0x158f8,0x1ac7e, // 20 351 | 0x1fac2,0x1587c,0x1f5d0,0x1faec,0x15df8,0x1f5c8,0x1fae6,0x15cfc,0x1f5c4,0x15c7e, // 30 352 | 0x1f5c2,0x1ebd0,0x1f5ec,0x1ebc8,0x1f5e6,0x1ebc4,0x1ebc2,0x1d7d0,0x1ebec,0x1d7c8, // 40 353 | 0x1ebe6,0x1d7c4,0x1d7c2,0x1afd0,0x1d7ec,0x1afc8,0x1d7e6,0x1afc4,0x14bc0,0x1a5f0, // 50 354 | 0x1d2fc,0x149e0,0x1a4f8,0x1d27e,0x148f0,0x1a47c,0x14878,0x1a43e,0x1483c,0x1fa68, // 60 355 | 0x14df0,0x1a6fc,0x1fa64,0x14cf8,0x1a67e,0x1fa62,0x14c7c,0x14c3e,0x1f4e8,0x1fa76, // 70 356 | 0x14efc,0x1f4e4,0x14e7e,0x1f4e2,0x1e9e8,0x1f4f6,0x1e9e4,0x1e9e2,0x1d3e8,0x1e9f6, // 80 357 | 0x1d3e4,0x1d3e2,0x1a7e8,0x1d3f6,0x1a7e4,0x1a7e2,0x145e0,0x1a2f8,0x1d17e,0x144f0, // 90 358 | 0x1a27c,0x14478,0x1a23e,0x1443c,0x1441e,0x1fa34,0x146f8,0x1a37e,0x1fa32,0x1467c, // 100 359 | 0x1463e,0x1f474,0x1477e,0x1f472,0x1e8f4,0x1e8f2,0x1d1f4,0x1d1f2,0x1a3f4,0x1a3f2, // 110 360 | 0x142f0,0x1a17c,0x14278,0x1a13e,0x1423c,0x1421e,0x1fa1a,0x1437c,0x1433e,0x1f43a, // 120 361 | 0x1e87a,0x1d0fa,0x14178,0x1a0be,0x1413c,0x1411e,0x141be,0x140bc,0x1409e,0x12bc0, // 130 362 | 0x195f0,0x1cafc,0x129e0,0x194f8,0x1ca7e,0x128f0,0x1947c,0x12878,0x1943e,0x1283c, // 140 363 | 0x1f968,0x12df0,0x196fc,0x1f964,0x12cf8,0x1967e,0x1f962,0x12c7c,0x12c3e,0x1f2e8, // 150 364 | 0x1f976,0x12efc,0x1f2e4,0x12e7e,0x1f2e2,0x1e5e8,0x1f2f6,0x1e5e4,0x1e5e2,0x1cbe8, // 160 365 | 0x1e5f6,0x1cbe4,0x1cbe2,0x197e8,0x1cbf6,0x197e4,0x197e2,0x1b5e0,0x1daf8,0x1ed7e, // 170 366 | 0x169c0,0x1b4f0,0x1da7c,0x168e0,0x1b478,0x1da3e,0x16870,0x1b43c,0x16838,0x1b41e, // 180 367 | 0x1681c,0x125e0,0x192f8,0x1c97e,0x16de0,0x124f0,0x1927c,0x16cf0,0x1b67c,0x1923e, // 190 368 | 0x16c78,0x1243c,0x16c3c,0x1241e,0x16c1e,0x1f934,0x126f8,0x1937e,0x1fb74,0x1f932, // 200 369 | 0x16ef8,0x1267c,0x1fb72,0x16e7c,0x1263e,0x16e3e,0x1f274,0x1277e,0x1f6f4,0x1f272, // 210 370 | 0x16f7e,0x1f6f2,0x1e4f4,0x1edf4,0x1e4f2,0x1edf2,0x1c9f4,0x1dbf4,0x1c9f2,0x1dbf2, // 220 371 | 0x193f4,0x193f2,0x165c0,0x1b2f0,0x1d97c,0x164e0,0x1b278,0x1d93e,0x16470,0x1b23c, // 230 372 | 0x16438,0x1b21e,0x1641c,0x1640e,0x122f0,0x1917c,0x166f0,0x12278,0x1913e,0x16678, // 240 373 | 0x1b33e,0x1663c,0x1221e,0x1661e,0x1f91a,0x1237c,0x1fb3a,0x1677c,0x1233e,0x1673e, // 250 374 | 0x1f23a,0x1f67a,0x1e47a,0x1ecfa,0x1c8fa,0x1d9fa,0x191fa,0x162e0,0x1b178,0x1d8be, // 260 375 | 0x16270,0x1b13c,0x16238,0x1b11e,0x1621c,0x1620e,0x12178,0x190be,0x16378,0x1213c, // 270 376 | 0x1633c,0x1211e,0x1631e,0x121be,0x163be,0x16170,0x1b0bc,0x16138,0x1b09e,0x1611c, // 280 377 | 0x1610e,0x120bc,0x161bc,0x1209e,0x1619e,0x160b8,0x1b05e,0x1609c,0x1608e,0x1205e, // 290 378 | 0x160de,0x1605c,0x1604e,0x115e0,0x18af8,0x1c57e,0x114f0,0x18a7c,0x11478,0x18a3e, // 300 379 | 0x1143c,0x1141e,0x1f8b4,0x116f8,0x18b7e,0x1f8b2,0x1167c,0x1163e,0x1f174,0x1177e, // 310 380 | 0x1f172,0x1e2f4,0x1e2f2,0x1c5f4,0x1c5f2,0x18bf4,0x18bf2,0x135c0,0x19af0,0x1cd7c, // 320 381 | 0x134e0,0x19a78,0x1cd3e,0x13470,0x19a3c,0x13438,0x19a1e,0x1341c,0x1340e,0x112f0, // 330 382 | 0x1897c,0x136f0,0x11278,0x1893e,0x13678,0x19b3e,0x1363c,0x1121e,0x1361e,0x1f89a, // 340 383 | 0x1137c,0x1f9ba,0x1377c,0x1133e,0x1373e,0x1f13a,0x1f37a,0x1e27a,0x1e6fa,0x1c4fa, // 350 384 | 0x1cdfa,0x189fa,0x1bae0,0x1dd78,0x1eebe,0x174c0,0x1ba70,0x1dd3c,0x17460,0x1ba38, // 360 385 | 0x1dd1e,0x17430,0x1ba1c,0x17418,0x1ba0e,0x1740c,0x132e0,0x19978,0x1ccbe,0x176e0, // 370 386 | 0x13270,0x1993c,0x17670,0x1bb3c,0x1991e,0x17638,0x1321c,0x1761c,0x1320e,0x1760e, // 380 387 | 0x11178,0x188be,0x13378,0x1113c,0x17778,0x1333c,0x1111e,0x1773c,0x1331e,0x1771e, // 390 388 | 0x111be,0x133be,0x177be,0x172c0,0x1b970,0x1dcbc,0x17260,0x1b938,0x1dc9e,0x17230, // 400 389 | 0x1b91c,0x17218,0x1b90e,0x1720c,0x17206,0x13170,0x198bc,0x17370,0x13138,0x1989e, // 410 390 | 0x17338,0x1b99e,0x1731c,0x1310e,0x1730e,0x110bc,0x131bc,0x1109e,0x173bc,0x1319e, // 420 391 | 0x1739e,0x17160,0x1b8b8,0x1dc5e,0x17130,0x1b89c,0x17118,0x1b88e,0x1710c,0x17106, // 430 392 | 0x130b8,0x1985e,0x171b8,0x1309c,0x1719c,0x1308e,0x1718e,0x1105e,0x130de,0x171de, // 440 393 | 0x170b0,0x1b85c,0x17098,0x1b84e,0x1708c,0x17086,0x1305c,0x170dc,0x1304e,0x170ce, // 450 394 | 0x17058,0x1b82e,0x1704c,0x17046,0x1302e,0x1706e,0x1702c,0x17026,0x10af0,0x1857c, // 460 395 | 0x10a78,0x1853e,0x10a3c,0x10a1e,0x10b7c,0x10b3e,0x1f0ba,0x1e17a,0x1c2fa,0x185fa, // 470 396 | 0x11ae0,0x18d78,0x1c6be,0x11a70,0x18d3c,0x11a38,0x18d1e,0x11a1c,0x11a0e,0x10978, // 480 397 | 0x184be,0x11b78,0x1093c,0x11b3c,0x1091e,0x11b1e,0x109be,0x11bbe,0x13ac0,0x19d70, // 490 398 | 0x1cebc,0x13a60,0x19d38,0x1ce9e,0x13a30,0x19d1c,0x13a18,0x19d0e,0x13a0c,0x13a06, // 500 399 | 0x11970,0x18cbc,0x13b70,0x11938,0x18c9e,0x13b38,0x1191c,0x13b1c,0x1190e,0x13b0e, // 510 400 | 0x108bc,0x119bc,0x1089e,0x13bbc,0x1199e,0x13b9e,0x1bd60,0x1deb8,0x1ef5e,0x17a40, // 520 401 | 0x1bd30,0x1de9c,0x17a20,0x1bd18,0x1de8e,0x17a10,0x1bd0c,0x17a08,0x1bd06,0x17a04, // 530 402 | 0x13960,0x19cb8,0x1ce5e,0x17b60,0x13930,0x19c9c,0x17b30,0x1bd9c,0x19c8e,0x17b18, // 540 403 | 0x1390c,0x17b0c,0x13906,0x17b06,0x118b8,0x18c5e,0x139b8,0x1189c,0x17bb8,0x1399c, // 550 404 | 0x1188e,0x17b9c,0x1398e,0x17b8e,0x1085e,0x118de,0x139de,0x17bde,0x17940,0x1bcb0, // 560 405 | 0x1de5c,0x17920,0x1bc98,0x1de4e,0x17910,0x1bc8c,0x17908,0x1bc86,0x17904,0x17902, // 570 406 | 0x138b0,0x19c5c,0x179b0,0x13898,0x19c4e,0x17998,0x1bcce,0x1798c,0x13886,0x17986, // 580 407 | 0x1185c,0x138dc,0x1184e,0x179dc,0x138ce,0x179ce,0x178a0,0x1bc58,0x1de2e,0x17890, // 590 408 | 0x1bc4c,0x17888,0x1bc46,0x17884,0x17882,0x13858,0x19c2e,0x178d8,0x1384c,0x178cc, // 600 409 | 0x13846,0x178c6,0x1182e,0x1386e,0x178ee,0x17850,0x1bc2c,0x17848,0x1bc26,0x17844, // 610 410 | 0x17842,0x1382c,0x1786c,0x13826,0x17866,0x17828,0x1bc16,0x17824,0x17822,0x13816, // 620 411 | 0x17836,0x10578,0x182be,0x1053c,0x1051e,0x105be,0x10d70,0x186bc,0x10d38,0x1869e, // 630 412 | 0x10d1c,0x10d0e,0x104bc,0x10dbc,0x1049e,0x10d9e,0x11d60,0x18eb8,0x1c75e,0x11d30, // 640 413 | 0x18e9c,0x11d18,0x18e8e,0x11d0c,0x11d06,0x10cb8,0x1865e,0x11db8,0x10c9c,0x11d9c, // 650 414 | 0x10c8e,0x11d8e,0x1045e,0x10cde,0x11dde,0x13d40,0x19eb0,0x1cf5c,0x13d20,0x19e98, // 660 415 | 0x1cf4e,0x13d10,0x19e8c,0x13d08,0x19e86,0x13d04,0x13d02,0x11cb0,0x18e5c,0x13db0, // 670 416 | 0x11c98,0x18e4e,0x13d98,0x19ece,0x13d8c,0x11c86,0x13d86,0x10c5c,0x11cdc,0x10c4e, // 680 417 | 0x13ddc,0x11cce,0x13dce,0x1bea0,0x1df58,0x1efae,0x1be90,0x1df4c,0x1be88,0x1df46, // 690 418 | 0x1be84,0x1be82,0x13ca0,0x19e58,0x1cf2e,0x17da0,0x13c90,0x19e4c,0x17d90,0x1becc, // 700 419 | 0x19e46,0x17d88,0x13c84,0x17d84,0x13c82,0x17d82,0x11c58,0x18e2e,0x13cd8,0x11c4c, // 710 420 | 0x17dd8,0x13ccc,0x11c46,0x17dcc,0x13cc6,0x17dc6,0x10c2e,0x11c6e,0x13cee,0x17dee, // 720 421 | 0x1be50,0x1df2c,0x1be48,0x1df26,0x1be44,0x1be42,0x13c50,0x19e2c,0x17cd0,0x13c48, // 730 422 | 0x19e26,0x17cc8,0x1be66,0x17cc4,0x13c42,0x17cc2,0x11c2c,0x13c6c,0x11c26,0x17cec, // 740 423 | 0x13c66,0x17ce6,0x1be28,0x1df16,0x1be24,0x1be22,0x13c28,0x19e16,0x17c68,0x13c24, // 750 424 | 0x17c64,0x13c22,0x17c62,0x11c16,0x13c36,0x17c76,0x1be14,0x1be12,0x13c14,0x17c34, // 760 425 | 0x13c12,0x17c32,0x102bc,0x1029e,0x106b8,0x1835e,0x1069c,0x1068e,0x1025e,0x106de, // 770 426 | 0x10eb0,0x1875c,0x10e98,0x1874e,0x10e8c,0x10e86,0x1065c,0x10edc,0x1064e,0x10ece, // 780 427 | 0x11ea0,0x18f58,0x1c7ae,0x11e90,0x18f4c,0x11e88,0x18f46,0x11e84,0x11e82,0x10e58, // 790 428 | 0x1872e,0x11ed8,0x18f6e,0x11ecc,0x10e46,0x11ec6,0x1062e,0x10e6e,0x11eee,0x19f50, // 800 429 | 0x1cfac,0x19f48,0x1cfa6,0x19f44,0x19f42,0x11e50,0x18f2c,0x13ed0,0x19f6c,0x18f26, // 810 430 | 0x13ec8,0x11e44,0x13ec4,0x11e42,0x13ec2,0x10e2c,0x11e6c,0x10e26,0x13eec,0x11e66, // 820 431 | 0x13ee6,0x1dfa8,0x1efd6,0x1dfa4,0x1dfa2,0x19f28,0x1cf96,0x1bf68,0x19f24,0x1bf64, // 830 432 | 0x19f22,0x1bf62,0x11e28,0x18f16,0x13e68,0x11e24,0x17ee8,0x13e64,0x11e22,0x17ee4, // 840 433 | 0x13e62,0x17ee2,0x10e16,0x11e36,0x13e76,0x17ef6,0x1df94,0x1df92,0x19f14,0x1bf34, // 850 434 | 0x19f12,0x1bf32,0x11e14,0x13e34,0x11e12,0x17e74,0x13e32,0x17e72,0x1df8a,0x19f0a, // 860 435 | 0x1bf1a,0x11e0a,0x13e1a,0x17e3a,0x1035c,0x1034e,0x10758,0x183ae,0x1074c,0x10746, // 870 436 | 0x1032e,0x1076e,0x10f50,0x187ac,0x10f48,0x187a6,0x10f44,0x10f42,0x1072c,0x10f6c, // 880 437 | 0x10726,0x10f66,0x18fa8,0x1c7d6,0x18fa4,0x18fa2,0x10f28,0x18796,0x11f68,0x18fb6, // 890 438 | 0x11f64,0x10f22,0x11f62,0x10716,0x10f36,0x11f76,0x1cfd4,0x1cfd2,0x18f94,0x19fb4, // 900 439 | 0x18f92,0x19fb2,0x10f14,0x11f34,0x10f12,0x13f74,0x11f32,0x13f72,0x1cfca,0x18f8a, // 910 440 | 0x19f9a,0x10f0a,0x11f1a,0x13f3a,0x103ac,0x103a6,0x107a8,0x183d6,0x107a4,0x107a2, // 920 441 | 0x10396,0x107b6,0x187d4,0x187d2,0x10794,0x10fb4,0x10792,0x10fb2,0x1c7ea) // 929 442 | ); // end of $clusters array 443 | 444 | /** 445 | * Array of factors of the Reed-Solomon polynomial equations used for error correction; one sub array for each correction level (0-8). 446 | * @protected 447 | */ 448 | protected $rsfactors = array( 449 | array( // ECL 0 (2 factors) ------------------------------------------------------------------------------- 450 | 0x01b,0x395), // 2 451 | array( // ECL 1 (4 factors) ------------------------------------------------------------------------------- 452 | 0x20a,0x238,0x2d3,0x329), // 4 453 | array( // ECL 2 (8 factors) ------------------------------------------------------------------------------- 454 | 0x0ed,0x134,0x1b4,0x11c,0x286,0x28d,0x1ac,0x17b), // 8 455 | array( // ECL 3 (16 factors) ------------------------------------------------------------------------------ 456 | 0x112,0x232,0x0e8,0x2f3,0x257,0x20c,0x321,0x084,0x127,0x074,0x1ba,0x1ac,0x127,0x02a,0x0b0,0x041),// 16 457 | array( // ECL 4 (32 factors) ------------------------------------------------------------------------------ 458 | 0x169,0x23f,0x39a,0x20d,0x0b0,0x24a,0x280,0x141,0x218,0x2e6,0x2a5,0x2e6,0x2af,0x11c,0x0c1,0x205, // 16 459 | 0x111,0x1ee,0x107,0x093,0x251,0x320,0x23b,0x140,0x323,0x085,0x0e7,0x186,0x2ad,0x14a,0x03f,0x19a),// 32 460 | array( // ECL 5 (64 factors) ------------------------------------------------------------------------------ 461 | 0x21b,0x1a6,0x006,0x05d,0x35e,0x303,0x1c5,0x06a,0x262,0x11f,0x06b,0x1f9,0x2dd,0x36d,0x17d,0x264, // 16 462 | 0x2d3,0x1dc,0x1ce,0x0ac,0x1ae,0x261,0x35a,0x336,0x21f,0x178,0x1ff,0x190,0x2a0,0x2fa,0x11b,0x0b8, // 32 463 | 0x1b8,0x023,0x207,0x01f,0x1cc,0x252,0x0e1,0x217,0x205,0x160,0x25d,0x09e,0x28b,0x0c9,0x1e8,0x1f6, // 48 464 | 0x288,0x2dd,0x2cd,0x053,0x194,0x061,0x118,0x303,0x348,0x275,0x004,0x17d,0x34b,0x26f,0x108,0x21f),// 64 465 | array( // ECL 6 (128 factors) ----------------------------------------------------------------------------- 466 | 0x209,0x136,0x360,0x223,0x35a,0x244,0x128,0x17b,0x035,0x30b,0x381,0x1bc,0x190,0x39d,0x2ed,0x19f, // 16 467 | 0x336,0x05d,0x0d9,0x0d0,0x3a0,0x0f4,0x247,0x26c,0x0f6,0x094,0x1bf,0x277,0x124,0x38c,0x1ea,0x2c0, // 32 468 | 0x204,0x102,0x1c9,0x38b,0x252,0x2d3,0x2a2,0x124,0x110,0x060,0x2ac,0x1b0,0x2ae,0x25e,0x35c,0x239, // 48 469 | 0x0c1,0x0db,0x081,0x0ba,0x0ec,0x11f,0x0c0,0x307,0x116,0x0ad,0x028,0x17b,0x2c8,0x1cf,0x286,0x308, // 64 470 | 0x0ab,0x1eb,0x129,0x2fb,0x09c,0x2dc,0x05f,0x10e,0x1bf,0x05a,0x1fb,0x030,0x0e4,0x335,0x328,0x382, // 80 471 | 0x310,0x297,0x273,0x17a,0x17e,0x106,0x17c,0x25a,0x2f2,0x150,0x059,0x266,0x057,0x1b0,0x29e,0x268, // 96 472 | 0x09d,0x176,0x0f2,0x2d6,0x258,0x10d,0x177,0x382,0x34d,0x1c6,0x162,0x082,0x32e,0x24b,0x324,0x022, // 112 473 | 0x0d3,0x14a,0x21b,0x129,0x33b,0x361,0x025,0x205,0x342,0x13b,0x226,0x056,0x321,0x004,0x06c,0x21b),// 128 474 | array( // ECL 7 (256 factors) ----------------------------------------------------------------------------- 475 | 0x20c,0x37e,0x04b,0x2fe,0x372,0x359,0x04a,0x0cc,0x052,0x24a,0x2c4,0x0fa,0x389,0x312,0x08a,0x2d0, // 16 476 | 0x35a,0x0c2,0x137,0x391,0x113,0x0be,0x177,0x352,0x1b6,0x2dd,0x0c2,0x118,0x0c9,0x118,0x33c,0x2f5, // 32 477 | 0x2c6,0x32e,0x397,0x059,0x044,0x239,0x00b,0x0cc,0x31c,0x25d,0x21c,0x391,0x321,0x2bc,0x31f,0x089, // 48 478 | 0x1b7,0x1a2,0x250,0x29c,0x161,0x35b,0x172,0x2b6,0x145,0x0f0,0x0d8,0x101,0x11c,0x225,0x0d1,0x374, // 64 479 | 0x13b,0x046,0x149,0x319,0x1ea,0x112,0x36d,0x0a2,0x2ed,0x32c,0x2ac,0x1cd,0x14e,0x178,0x351,0x209, // 80 480 | 0x133,0x123,0x323,0x2c8,0x013,0x166,0x18f,0x38c,0x067,0x1ff,0x033,0x008,0x205,0x0e1,0x121,0x1d6, // 96 481 | 0x27d,0x2db,0x042,0x0ff,0x395,0x10d,0x1cf,0x33e,0x2da,0x1b1,0x350,0x249,0x088,0x21a,0x38a,0x05a, // 112 482 | 0x002,0x122,0x2e7,0x0c7,0x28f,0x387,0x149,0x031,0x322,0x244,0x163,0x24c,0x0bc,0x1ce,0x00a,0x086, // 128 483 | 0x274,0x140,0x1df,0x082,0x2e3,0x047,0x107,0x13e,0x176,0x259,0x0c0,0x25d,0x08e,0x2a1,0x2af,0x0ea, // 144 484 | 0x2d2,0x180,0x0b1,0x2f0,0x25f,0x280,0x1c7,0x0c1,0x2b1,0x2c3,0x325,0x281,0x030,0x03c,0x2dc,0x26d, // 160 485 | 0x37f,0x220,0x105,0x354,0x28f,0x135,0x2b9,0x2f3,0x2f4,0x03c,0x0e7,0x305,0x1b2,0x1a5,0x2d6,0x210, // 176 486 | 0x1f7,0x076,0x031,0x31b,0x020,0x090,0x1f4,0x0ee,0x344,0x18a,0x118,0x236,0x13f,0x009,0x287,0x226, // 192 487 | 0x049,0x392,0x156,0x07e,0x020,0x2a9,0x14b,0x318,0x26c,0x03c,0x261,0x1b9,0x0b4,0x317,0x37d,0x2f2, // 208 488 | 0x25d,0x17f,0x0e4,0x2ed,0x2f8,0x0d5,0x036,0x129,0x086,0x036,0x342,0x12b,0x39a,0x0bf,0x38e,0x214, // 224 489 | 0x261,0x33d,0x0bd,0x014,0x0a7,0x01d,0x368,0x1c1,0x053,0x192,0x029,0x290,0x1f9,0x243,0x1e1,0x0ad, // 240 490 | 0x194,0x0fb,0x2b0,0x05f,0x1f1,0x22b,0x282,0x21f,0x133,0x09f,0x39c,0x22e,0x288,0x037,0x1f1,0x00a),// 256 491 | array( // ECL 8 (512 factors) ----------------------------------------------------------------------------- 492 | 0x160,0x04d,0x175,0x1f8,0x023,0x257,0x1ac,0x0cf,0x199,0x23e,0x076,0x1f2,0x11d,0x17c,0x15e,0x1ec, // 16 493 | 0x0c5,0x109,0x398,0x09b,0x392,0x12b,0x0e5,0x283,0x126,0x367,0x132,0x058,0x057,0x0c1,0x160,0x30d, // 32 494 | 0x34e,0x04b,0x147,0x208,0x1b3,0x21f,0x0cb,0x29a,0x0f9,0x15a,0x30d,0x26d,0x280,0x10c,0x31a,0x216, // 48 495 | 0x21b,0x30d,0x198,0x186,0x284,0x066,0x1dc,0x1f3,0x122,0x278,0x221,0x025,0x35a,0x394,0x228,0x029, // 64 496 | 0x21e,0x121,0x07a,0x110,0x17f,0x320,0x1e5,0x062,0x2f0,0x1d8,0x2f9,0x06b,0x310,0x35c,0x292,0x2e5, // 80 497 | 0x122,0x0cc,0x2a9,0x197,0x357,0x055,0x063,0x03e,0x1e2,0x0b4,0x014,0x129,0x1c3,0x251,0x391,0x08e, // 96 498 | 0x328,0x2ac,0x11f,0x218,0x231,0x04c,0x28d,0x383,0x2d9,0x237,0x2e8,0x186,0x201,0x0c0,0x204,0x102, // 112 499 | 0x0f0,0x206,0x31a,0x18b,0x300,0x350,0x033,0x262,0x180,0x0a8,0x0be,0x33a,0x148,0x254,0x312,0x12f, // 128 500 | 0x23a,0x17d,0x19f,0x281,0x09c,0x0ed,0x097,0x1ad,0x213,0x0cf,0x2a4,0x2c6,0x059,0x0a8,0x130,0x192, // 144 501 | 0x028,0x2c4,0x23f,0x0a2,0x360,0x0e5,0x041,0x35d,0x349,0x200,0x0a4,0x1dd,0x0dd,0x05c,0x166,0x311, // 160 502 | 0x120,0x165,0x352,0x344,0x33b,0x2e0,0x2c3,0x05e,0x008,0x1ee,0x072,0x209,0x002,0x1f3,0x353,0x21f, // 176 503 | 0x098,0x2d9,0x303,0x05f,0x0f8,0x169,0x242,0x143,0x358,0x31d,0x121,0x033,0x2ac,0x1d2,0x215,0x334, // 192 504 | 0x29d,0x02d,0x386,0x1c4,0x0a7,0x156,0x0f4,0x0ad,0x023,0x1cf,0x28b,0x033,0x2bb,0x24f,0x1c4,0x242, // 208 505 | 0x025,0x07c,0x12a,0x14c,0x228,0x02b,0x1ab,0x077,0x296,0x309,0x1db,0x352,0x2fc,0x16c,0x242,0x38f, // 224 506 | 0x11b,0x2c7,0x1d8,0x1a4,0x0f5,0x120,0x252,0x18a,0x1ff,0x147,0x24d,0x309,0x2bb,0x2b0,0x02b,0x198, // 240 507 | 0x34a,0x17f,0x2d1,0x209,0x230,0x284,0x2ca,0x22f,0x03e,0x091,0x369,0x297,0x2c9,0x09f,0x2a0,0x2d9, // 256 508 | 0x270,0x03b,0x0c1,0x1a1,0x09e,0x0d1,0x233,0x234,0x157,0x2b5,0x06d,0x260,0x233,0x16d,0x0b5,0x304, // 272 509 | 0x2a5,0x136,0x0f8,0x161,0x2c4,0x19a,0x243,0x366,0x269,0x349,0x278,0x35c,0x121,0x218,0x023,0x309, // 288 510 | 0x26a,0x24a,0x1a8,0x341,0x04d,0x255,0x15a,0x10d,0x2f5,0x278,0x2b7,0x2ef,0x14b,0x0f7,0x0b8,0x02d, // 304 511 | 0x313,0x2a8,0x012,0x042,0x197,0x171,0x036,0x1ec,0x0e4,0x265,0x33e,0x39a,0x1b5,0x207,0x284,0x389, // 320 512 | 0x315,0x1a4,0x131,0x1b9,0x0cf,0x12c,0x37c,0x33b,0x08d,0x219,0x17d,0x296,0x201,0x038,0x0fc,0x155, // 336 513 | 0x0f2,0x31d,0x346,0x345,0x2d0,0x0e0,0x133,0x277,0x03d,0x057,0x230,0x136,0x2f4,0x299,0x18d,0x328, // 352 514 | 0x353,0x135,0x1d9,0x31b,0x17a,0x01f,0x287,0x393,0x1cb,0x326,0x24e,0x2db,0x1a9,0x0d8,0x224,0x0f9, // 368 515 | 0x141,0x371,0x2bb,0x217,0x2a1,0x30e,0x0d2,0x32f,0x389,0x12f,0x34b,0x39a,0x119,0x049,0x1d5,0x317, // 384 516 | 0x294,0x0a2,0x1f2,0x134,0x09b,0x1a6,0x38b,0x331,0x0bb,0x03e,0x010,0x1a9,0x217,0x150,0x11e,0x1b5, // 400 517 | 0x177,0x111,0x262,0x128,0x0b7,0x39b,0x074,0x29b,0x2ef,0x161,0x03e,0x16e,0x2b3,0x17b,0x2af,0x34a, // 416 518 | 0x025,0x165,0x2d0,0x2e6,0x14a,0x005,0x027,0x39b,0x137,0x1a8,0x0f2,0x2ed,0x141,0x036,0x29d,0x13c, // 432 519 | 0x156,0x12b,0x216,0x069,0x29b,0x1e8,0x280,0x2a0,0x240,0x21c,0x13c,0x1e6,0x2d1,0x262,0x02e,0x290, // 448 520 | 0x1bf,0x0ab,0x268,0x1d0,0x0be,0x213,0x129,0x141,0x2fa,0x2f0,0x215,0x0af,0x086,0x00e,0x17d,0x1b1, // 464 521 | 0x2cd,0x02d,0x06f,0x014,0x254,0x11c,0x2e0,0x08a,0x286,0x19b,0x36d,0x29d,0x08d,0x397,0x02d,0x30c, // 480 522 | 0x197,0x0a4,0x14c,0x383,0x0a5,0x2d6,0x258,0x145,0x1f2,0x28f,0x165,0x2f0,0x300,0x0df,0x351,0x287, // 496 523 | 0x03f,0x136,0x35f,0x0fb,0x16e,0x130,0x11a,0x2e2,0x2a3,0x19a,0x185,0x0f4,0x01f,0x079,0x12f,0x107) // 512 524 | ); 525 | 526 | /** 527 | * This is the class constructor. 528 | * Creates a PDF417 object 529 | * @param string $code code to represent using PDF417 530 | * @param int $ecl error correction level (0-8); default -1 = automatic correction level 531 | * @param float $aspectratio the width to height of the symbol (excluding quiet zones) 532 | * @param array $macro information for macro block 533 | * @public 534 | */ 535 | public function __construct($code, $ecl=-1, $aspectratio=2, $macro=array()) { 536 | $barcode_array = array(); 537 | if ((is_null($code)) OR ($code == '\0') OR ($code == '')) { 538 | return false; 539 | } 540 | // get the input sequence array 541 | $sequence = $this->getInputSequences($code); 542 | $codewords = array(); // array of code-words 543 | foreach($sequence as $seq) { 544 | $cw = $this->getCompaction($seq[0], $seq[1], true); 545 | $codewords = array_merge($codewords, $cw); 546 | } 547 | if ($codewords[0] == 900) { 548 | // Text Alpha is the default mode, so remove the first code 549 | array_shift($codewords); 550 | } 551 | // count number of codewords 552 | $numcw = count($codewords); 553 | if ($numcw > 925) { 554 | // reached maximum data codeword capacity 555 | return false; 556 | } 557 | // build macro control block codewords 558 | if (!empty($macro)) { 559 | $macrocw = array(); 560 | // beginning of macro control block 561 | $macrocw[] = 928; 562 | // segment index 563 | $cw = $this->getCompaction(902, sprintf('%05d', $macro['segment_index']), false); 564 | $macrocw = array_merge($macrocw, $cw); 565 | // file ID 566 | $cw = $this->getCompaction(900, $macro['file_id'], false); 567 | $macrocw = array_merge($macrocw, $cw); 568 | // optional fields 569 | $optmodes = array(900,902,902,900,900,902,902); 570 | $optsize = array(-1,2,4,-1,-1,-1,2); 571 | foreach ($optmodes as $k => $omode) { 572 | if (isset($macro['option_'.$k])) { 573 | $macrocw[] = 923; 574 | $macrocw[] = $k; 575 | if ($optsize[$k] == 2) { 576 | $macro['option_'.$k] = sprintf('%05d', $macro['option_'.$k]); 577 | } elseif ($optsize[$k] == 4) { 578 | $macro['option_'.$k] = sprintf('%010d', $macro['option_'.$k]); 579 | } 580 | $cw = $this->getCompaction($omode, $macro['option_'.$k], false); 581 | $macrocw = array_merge($macrocw, $cw); 582 | } 583 | } 584 | if ($macro['segment_index'] == ($macro['segment_total'] - 1)) { 585 | // end of control block 586 | $macrocw[] = 922; 587 | } 588 | // update total codewords 589 | $numcw += count($macrocw); 590 | } 591 | // set error correction level 592 | $ecl = $this->getErrorCorrectionLevel($ecl, $numcw); 593 | // number of codewords for error correction 594 | $errsize = (2 << $ecl); 595 | // calculate number of columns (number of codewords per row) and rows 596 | $nce = ($numcw + $errsize + 1); 597 | $cols = round((sqrt(4761 + (68 * $aspectratio * ROWHEIGHT * $nce)) - 69) / 34); 598 | // adjust cols 599 | if ($cols < 1) { 600 | $cols = 1; 601 | } elseif ($cols > 30) { 602 | $cols = 30; 603 | } 604 | $rows = ceil($nce / $cols); 605 | $size = ($cols * $rows); 606 | // adjust rows 607 | if (($rows < 3) OR ($rows > 90)) { 608 | if ($rows < 3) { 609 | $rows = 3; 610 | } elseif ($rows > 90) { 611 | $rows = 90; 612 | } 613 | $cols = ceil($size / $rows); 614 | $size = ($cols * $rows); 615 | } 616 | if ($size > 928) { 617 | // set dimensions to get maximum capacity 618 | if (abs($aspectratio - (17 * 29 / 32)) < abs($aspectratio - (17 * 16 / 58))) { 619 | $cols = 29; 620 | $rows = 32; 621 | } else { 622 | $cols = 16; 623 | $rows = 58; 624 | } 625 | $size = 928; 626 | } 627 | // calculate padding 628 | $pad = ($size - $nce); 629 | if ($pad > 0) { 630 | if (($size - $rows) == $nce) { 631 | --$rows; 632 | $size -= $rows; 633 | } else { 634 | // add pading 635 | $codewords = array_merge($codewords, array_fill(0, $pad, 900)); 636 | } 637 | } 638 | if (!empty($macro)) { 639 | // add macro section 640 | $codewords = array_merge($codewords, $macrocw); 641 | } 642 | // Symbol Length Descriptor (number of data codewords including Symbol Length Descriptor and pad codewords) 643 | $sld = $size - $errsize; 644 | // add symbol length description 645 | array_unshift($codewords, $sld); 646 | // calculate error correction 647 | $ecw = $this->getErrorCorrection($codewords, $ecl); 648 | // add error correction codewords 649 | $codewords = array_merge($codewords, $ecw); 650 | // add horizontal quiet zones to start and stop patterns 651 | $pstart = str_repeat('0', QUIETH).$this->start_pattern; 652 | $pstop = $this->stop_pattern.str_repeat('0', QUIETH); 653 | $barcode_array['num_rows'] = ($rows * ROWHEIGHT) + (2 * QUIETV); 654 | $barcode_array['num_cols'] = (($cols + 2) * 17) + 35 + (2 * QUIETH); 655 | $barcode_array['bcode'] = array(); 656 | // build rows for vertical quiet zone 657 | if (QUIETV > 0) { 658 | $empty_row = array_fill(0, $barcode_array['num_cols'], 0); 659 | for ($i = 0; $i < QUIETV; ++$i) { 660 | // add vertical quiet rows 661 | $barcode_array['bcode'][] = $empty_row; 662 | } 663 | } 664 | $k = 0; // codeword index 665 | $cid = 0; // initial cluster 666 | // for each row 667 | for ($r = 0; $r < $rows; ++$r) { 668 | // row start code 669 | $row = $pstart; 670 | switch ($cid) { 671 | case 0: { 672 | $L = ((30 * intval($r / 3)) + intval(($rows - 1) / 3)); 673 | break; 674 | } 675 | case 1: { 676 | $L = ((30 * intval($r / 3)) + ($ecl * 3) + (($rows - 1) % 3)); 677 | break; 678 | } 679 | case 2: { 680 | $L = ((30 * intval($r / 3)) + ($cols - 1)); 681 | break; 682 | } 683 | } 684 | // left row indicator 685 | $row .= sprintf('%17b', $this->clusters[$cid][$L]); 686 | // for each column 687 | for ($c = 0; $c < $cols; ++$c) { 688 | $row .= sprintf('%17b', $this->clusters[$cid][$codewords[$k]]); 689 | ++$k; 690 | } 691 | switch ($cid) { 692 | case 0: { 693 | $L = ((30 * intval($r / 3)) + ($cols - 1)); 694 | break; 695 | } 696 | case 1: { 697 | $L = ((30 * intval($r / 3)) + intval(($rows - 1) / 3)); 698 | break; 699 | } 700 | case 2: { 701 | $L = ((30 * intval($r / 3)) + ($ecl * 3) + (($rows - 1) % 3)); 702 | break; 703 | } 704 | } 705 | // right row indicator 706 | $row .= sprintf('%17b', $this->clusters[$cid][$L]); 707 | // row stop code 708 | $row .= $pstop; 709 | // convert the string to array 710 | $arow = preg_split('//', $row, -1, PREG_SPLIT_NO_EMPTY); 711 | // duplicate row to get the desired height 712 | for ($h = 0; $h < ROWHEIGHT; ++$h) { 713 | $barcode_array['bcode'][] = $arow; 714 | } 715 | ++$cid; 716 | if ($cid > 2) { 717 | $cid = 0; 718 | } 719 | } 720 | if (QUIETV > 0) { 721 | for ($i = 0; $i < QUIETV; ++$i) { 722 | // add vertical quiet rows 723 | $barcode_array['bcode'][] = $empty_row; 724 | } 725 | } 726 | $this->barcode_array = $barcode_array; 727 | } 728 | 729 | /** 730 | * Returns a barcode array which is readable by TCPDF 731 | * @return array barcode array readable by TCPDF; 732 | * @public 733 | */ 734 | public function getBarcodeArray() { 735 | return $this->barcode_array; 736 | } 737 | 738 | /** 739 | * Returns the error correction level (0-8) to be used 740 | * @param int $ecl error correction level 741 | * @param int $numcw number of data codewords 742 | * @return int error correction level 743 | * @protected 744 | */ 745 | protected function getErrorCorrectionLevel($ecl, $numcw) { 746 | $maxecl = 8; // starting error level 747 | // check for automatic levels 748 | if (($ecl < 0) OR ($ecl > 8)) { 749 | if ($numcw < 41) { 750 | $ecl = 2; 751 | } elseif ($numcw < 161) { 752 | $ecl = 3; 753 | } elseif ($numcw < 321) { 754 | $ecl = 4; 755 | } elseif ($numcw < 864) { 756 | $ecl = 5; 757 | } else { 758 | $ecl = $maxecl; 759 | } 760 | } 761 | // get maximum correction level 762 | $maxerrsize = (928 - $numcw); // available codewords for error 763 | while ($maxecl > 0) { 764 | $errsize = (2 << $ecl); 765 | if ($maxerrsize >= $errsize) { 766 | break; 767 | } 768 | --$maxecl; 769 | } 770 | if ($ecl > $maxecl) { 771 | $ecl = $maxecl; 772 | } 773 | return $ecl; 774 | } 775 | 776 | /** 777 | * Returns the error correction codewords 778 | * @param array $cw array of codewords including Symbol Length Descriptor and pad 779 | * @param int $ecl error correction level 0-8 780 | * @return array of error correction codewords 781 | * @protected 782 | */ 783 | protected function getErrorCorrection($cw, $ecl) { 784 | // get error correction coefficients 785 | $ecc = $this->rsfactors[$ecl]; 786 | // number of error correction factors 787 | $eclsize = (2 << $ecl); 788 | // maximum index for $rsfactors[$ecl] 789 | $eclmaxid = ($eclsize - 1); 790 | // initialize array of error correction codewords 791 | $ecw = array_fill(0, $eclsize, 0); 792 | // for each data codeword 793 | foreach($cw as $k => $d) { 794 | $t1 = ($d + $ecw[$eclmaxid]) % 929; 795 | for ($j = $eclmaxid; $j > 0; --$j) { 796 | $t2 = ($t1 * $ecc[$j]) % 929; 797 | $t3 = 929 - $t2; 798 | $ecw[$j] = ($ecw[($j - 1)] + $t3) % 929; 799 | } 800 | $t2 = ($t1 * $ecc[0]) % 929; 801 | $t3 = 929 - $t2; 802 | $ecw[0] = $t3 % 929; 803 | } 804 | foreach($ecw as $j => $e) { 805 | if ($e != 0) { 806 | $ecw[$j] = 929 - $e; 807 | } 808 | } 809 | $ecw = array_reverse($ecw); 810 | return $ecw; 811 | } 812 | 813 | /** 814 | * Create array of sequences from input 815 | * @param string $code code 816 | * @return array bi-dimensional array containing characters and classification 817 | * @protected 818 | */ 819 | protected function getInputSequences($code) { 820 | $sequence_array = array(); // array to be returned 821 | $numseq = array(); 822 | // get numeric sequences 823 | preg_match_all('/([0-9]{13,44})/', $code, $numseq, PREG_OFFSET_CAPTURE); 824 | $numseq[1][] = array('', strlen($code)); 825 | $offset = 0; 826 | foreach($numseq[1] as $seq) { 827 | $seqlen = strlen($seq[0]); 828 | if ($seq[1] > 0) { 829 | // extract text sequence before the number sequence 830 | $prevseq = substr($code, $offset, ($seq[1] - $offset)); 831 | $textseq = array(); 832 | // get text sequences 833 | preg_match_all('/([\x09\x0a\x0d\x20-\x7e]{5,})/', $prevseq, $textseq, PREG_OFFSET_CAPTURE); 834 | $textseq[1][] = array('', strlen($prevseq)); 835 | $txtoffset = 0; 836 | foreach($textseq[1] as $txtseq) { 837 | $txtseqlen = strlen($txtseq[0]); 838 | if ($txtseq[1] > 0) { 839 | // extract byte sequence before the text sequence 840 | $prevtxtseq = substr($prevseq, $txtoffset, ($txtseq[1] - $txtoffset)); 841 | if (strlen($prevtxtseq) > 0) { 842 | // add BYTE sequence 843 | if ((strlen($prevtxtseq) == 1) AND ((count($sequence_array) > 0) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) { 844 | $sequence_array[] = array(913, $prevtxtseq); 845 | } elseif ((strlen($prevtxtseq) % 6) == 0) { 846 | $sequence_array[] = array(924, $prevtxtseq); 847 | } else { 848 | $sequence_array[] = array(901, $prevtxtseq); 849 | } 850 | } 851 | } 852 | if ($txtseqlen > 0) { 853 | // add numeric sequence 854 | $sequence_array[] = array(900, $txtseq[0]); 855 | } 856 | $txtoffset = $txtseq[1] + $txtseqlen; 857 | } 858 | } 859 | if ($seqlen > 0) { 860 | // add numeric sequence 861 | $sequence_array[] = array(902, $seq[0]); 862 | } 863 | $offset = $seq[1] + $seqlen; 864 | } 865 | return $sequence_array; 866 | } 867 | 868 | /** 869 | * Compact data by mode. 870 | * @param int $mode compaction mode number 871 | * @param string $code data to compact 872 | * @param boolean $addmode if true add the mode codeword at first position 873 | * @return array of codewords 874 | * @protected 875 | */ 876 | protected function getCompaction($mode, $code, $addmode=true) { 877 | $cw = array(); // array of codewords to return 878 | switch($mode) { 879 | case 900: { // Text Compaction mode latch 880 | $submode = 0; // default Alpha sub-mode 881 | $txtarr = array(); // array of characters and sub-mode switching characters 882 | $codelen = strlen($code); 883 | for ($i = 0; $i < $codelen; ++$i) { 884 | $chval = ord($code[$i]); 885 | if (($k = array_search($chval, $this->textsubmodes[$submode])) !== false) { 886 | // we are on the same sub-mode 887 | $txtarr[] = $k; 888 | } else { 889 | // the sub-mode is changed 890 | for ($s = 0; $s < 4; ++$s) { 891 | // search new sub-mode 892 | if (($s != $submode) AND (($k = array_search($chval, $this->textsubmodes[$s])) !== false)) { 893 | // $s is the new submode 894 | if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code[($i + 1)]), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { 895 | // shift (temporary change only for this char) 896 | if ($s == 3) { 897 | // shift to puntuaction 898 | $txtarr[] = 29; 899 | } else { 900 | // shift from lower to alpha 901 | $txtarr[] = 27; 902 | } 903 | } else { 904 | // latch 905 | $txtarr = array_merge($txtarr, $this->textlatch[''.$submode.$s]); 906 | // set new submode 907 | $submode = $s; 908 | } 909 | // add characted code to array 910 | $txtarr[] = $k; 911 | break; 912 | } 913 | } 914 | } 915 | } 916 | $txtarrlen = count($txtarr); 917 | if (($txtarrlen % 2) != 0) { 918 | // add padding 919 | $txtarr[] = 29; 920 | ++$txtarrlen; 921 | } 922 | // calculate codewords 923 | for ($i = 0; $i < $txtarrlen; $i += 2) { 924 | $cw[] = (30 * $txtarr[$i]) + $txtarr[($i + 1)]; 925 | } 926 | break; 927 | } 928 | case 901: 929 | case 924: { // Byte Compaction mode latch 930 | while (($codelen = strlen($code)) > 0) { 931 | if ($codelen > 6) { 932 | $rest = substr($code, 6); 933 | $code = substr($code, 0, 6); 934 | $sublen = 6; 935 | } else { 936 | $rest = ''; 937 | $sublen = strlen($code); 938 | } 939 | if ($sublen == 6) { 940 | $t = bcmul(''.ord($code[0]), '1099511627776'); 941 | $t = bcadd($t, bcmul(''.ord($code[1]), '4294967296')); 942 | $t = bcadd($t, bcmul(''.ord($code[2]), '16777216')); 943 | $t = bcadd($t, bcmul(''.ord($code[3]), '65536')); 944 | $t = bcadd($t, bcmul(''.ord($code[4]), '256')); 945 | $t = bcadd($t, ''.ord($code[5])); 946 | // tmp array for the 6 bytes block 947 | $cw6 = array(); 948 | do { 949 | $d = bcmod($t, '900'); 950 | $t = bcdiv($t, '900'); 951 | // prepend the value to the beginning of the array 952 | array_unshift($cw6, $d); 953 | } while ($t != '0'); 954 | // append the result array at the end 955 | $cw = array_merge($cw, $cw6); 956 | } else { 957 | for ($i = 0; $i < $sublen; ++$i) { 958 | $cw[] = ord($code[$i]); 959 | } 960 | } 961 | $code = $rest; 962 | } 963 | break; 964 | } 965 | case 902: { // Numeric Compaction mode latch 966 | while (($codelen = strlen($code)) > 0) { 967 | if ($codelen > 44) { 968 | $rest = substr($code, 44); 969 | $code = substr($code, 0, 44); 970 | } else { 971 | $rest = ''; 972 | } 973 | $t = '1'.$code; 974 | do { 975 | $d = bcmod($t, '900'); 976 | $t = bcdiv($t, '900'); 977 | array_unshift($cw, $d); 978 | } while ($t != '0'); 979 | $code = $rest; 980 | } 981 | break; 982 | } 983 | case 913: { // Byte Compaction mode shift 984 | $cw[] = ord($code); 985 | break; 986 | } 987 | } 988 | if ($addmode) { 989 | // add the compaction mode codeword at the beginning 990 | array_unshift($cw, $mode); 991 | } 992 | return $cw; 993 | } 994 | 995 | } // end PDF417 class 996 | 997 | //============================================================+ 998 | // END OF FILE 999 | //============================================================+ 1000 | --------------------------------------------------------------------------------