File manager - Edit - /home/opticamezl/www/newok/Barcode.zip
Back
PK �2�\�� X Msi.phpnu &1i� <?php namespace Mpdf\Barcode; /** * MSI - Variation of Plessey code, with similar applications * Contains digits (0 to 9) and encodes the data only in the width of bars. */ class Msi extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param int $code * @param bool $checksum */ public function __construct($code, $checksum = false) { $this->init($code, $checksum); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 12; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 12; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param int $code * @param bool $checksum */ private function init($code, $checksum) { $chr = [ '0' => '100100100100', '1' => '100100100110', '2' => '100100110100', '3' => '100100110110', '4' => '100110100100', '5' => '100110100110', '6' => '100110110100', '7' => '100110110110', '8' => '110100100100', '9' => '110100100110', 'A' => '110100110100', 'B' => '110100110110', 'C' => '110110100100', 'D' => '110110100110', 'E' => '110110110100', 'F' => '110110110110', ]; $checkdigit = ''; if ($checksum) { // add checksum $clen = strlen($code); $p = 2; $check = 0; for ($i = ($clen - 1); $i >= 0; --$i) { $check += (hexdec($code[$i]) * $p); ++$p; if ($p > 7) { $p = 2; } } $check %= 11; if ($check > 0) { $check = 11 - $check; } $code .= $check; $checkdigit = $check; } $seq = '110'; // left guard $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { $digit = $code[$i]; if (!isset($chr[$digit])) { // invalid character throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in MSI barcode value', $digit)); } $seq .= $chr[$digit]; } $seq .= '1001'; // right guard $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $bararray['checkdigit'] = $checkdigit; $this->data = $this->binseqToArray($seq, $bararray); } /** * @inheritdoc */ public function getType() { return 'MSI'; } } PK �2�\@��X X I25.phpnu &1i� <?php namespace Mpdf\Barcode; /** * Interleaved 2 of 5 barcodes. * Compact numeric code, widely used in industry, air cargo * Contains digits (0 to 9) and encodes the data in the width of both bars and spaces. */ class I25 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $topBottomMargin * @param float $printRatio * @param bool $checksum */ public function __construct($code, $topBottomMargin, $printRatio, $checksum = false) { $this->init($code, $printRatio, $checksum); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = $topBottomMargin; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code * @param float $printRatio * @param bool $checksum */ private function init($code, $printRatio, $checksum) { $chr = [ '0' => '11221', '1' => '21112', '2' => '12112', '3' => '22111', '4' => '11212', '5' => '21211', '6' => '12211', '7' => '11122', '8' => '21121', '9' => '12121', 'A' => '11', 'Z' => '21', ]; $checkdigit = ''; if ($checksum) { // add checksum $checkdigit = $this->checksum($code); $code .= $checkdigit; } if ((strlen($code) % 2) != 0) { // add leading zero if code-length is odd $code = '0' . $code; } // add start and stop codes $code = 'AA' . strtolower($code) . 'ZA'; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $k = 0; $clen = strlen($code); for ($i = 0; $i < $clen; $i = ($i + 2)) { $charBar = $code[$i]; $charSpace = $code[$i + 1]; if ((!isset($chr[$charBar])) or (!isset($chr[$charSpace]))) { // invalid character throw new \Mpdf\Barcode\BarcodeException('Invalid I25 barcode value'); } // create a bar-space sequence $seq = ''; $chrlen = strlen($chr[$charBar]); for ($s = 0; $s < $chrlen; $s++) { $seq .= $chr[$charBar][$s] . $chr[$charSpace][$s]; } $seqlen = strlen($seq); for ($j = 0; $j < $seqlen; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } $x = $seq[$j]; if ($x == 2) { $w = $printRatio; } else { $w = 1; } $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; } } $bararray['checkdigit'] = $checkdigit; $this->data = $bararray; } /** * Checksum for standard 2 of 5 barcodes. * * @param string $code * @return int */ private function checksum($code) { $len = strlen($code); $sum = 0; for ($i = 0; $i < $len; $i += 2) { $sum += $code[$i]; } $sum *= 3; for ($i = 1; $i < $len; $i += 2) { $sum += ($code[$i]); } $r = $sum % 10; if ($r > 0) { $r = (10 - $r); } return $r; } /** * @inheritdoc */ public function getType() { return 'I25'; } } PK �2�\q�@� � Code11.phpnu &1i� <?php namespace Mpdf\Barcode; /** * CODE11 barcodes. * Used primarily for labeling telecommunications equipment */ class Code11 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $printRatio */ public function __construct($code, $printRatio) { $this->init($code, $printRatio); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code * @param float $printRatio */ private function init($code, $printRatio) { $chr = [ '0' => '111121', '1' => '211121', '2' => '121121', '3' => '221111', '4' => '112121', '5' => '212111', '6' => '122111', '7' => '111221', '8' => '211211', '9' => '211111', '-' => '112111', 'S' => '112211' ]; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $k = 0; $len = strlen($code); // calculate check digit C $p = 1; $check = 0; for ($i = ($len - 1); $i >= 0; --$i) { $digit = $code[$i]; if ($digit == '-') { $dval = 10; } else { $dval = (int) $digit; } $check += ($dval * $p); ++$p; if ($p > 10) { $p = 1; } } $check %= 11; if ($check == 10) { $check = '-'; } $code .= $check; $checkdigit = $check; if ($len > 10) { // calculate check digit K $p = 1; $check = 0; for ($i = $len; $i >= 0; --$i) { $digit = $code[$i]; if ($digit == '-') { $dval = 10; } else { $dval = (int) $digit; } $check += ($dval * $p); ++$p; if ($p > 9) { $p = 1; } } $check %= 11; $code .= $check; $checkdigit .= $check; ++$len; } $code = 'S' . $code . 'S'; $len += 3; for ($i = 0; $i < $len; ++$i) { if (!isset($chr[$code[$i]])) { throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in CODE11 barcode value', $code[$i])); } $seq = $chr[$code[$i]]; for ($j = 0; $j < 6; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } $x = $seq[$j]; if ($x == 2) { $w = $printRatio; } else { $w = 1; } $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; } } $bararray['checkdigit'] = $checkdigit; $this->data = $bararray; } /** * @inheritdoc */ public function getType() { return 'CODE11'; } } PK �2�\lm�HO O AbstractBarcode.phpnu &1i� <?php namespace Mpdf\Barcode; abstract class AbstractBarcode { /** * @var mixed[] */ protected $data; /** * @return mixed[] */ public function getData() { return $this->data; } /** * @param string $key * * @return mixed */ public function getKey($key) { return isset($this->data[$key]) ? $this->data[$key] : null; } /** * @return string */ public function getChecksum() { return $this->getKey('checkdigit'); } /** * Convert binary barcode sequence to barcode array * * @param string $seq * @param mixed[] $barcodeData * * @return mixed[] */ protected function binseqToArray($seq, array $barcodeData) { $len = strlen($seq); $w = 0; $k = 0; for ($i = 0; $i < $len; ++$i) { $w += 1; if (($i == ($len - 1)) or (($i < ($len - 1)) and ($seq[$i] != $seq[($i + 1)]))) { if ($seq[$i] == '1') { $t = true; // bar } else { $t = false; // space } $barcodeData['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $barcodeData['maxw'] += $w; ++$k; $w = 0; } } return $barcodeData; } } PK �2�\5-�C� � S25.phpnu &1i� <?php namespace Mpdf\Barcode; /** * Standard 2 of 5 barcodes. * Used in airline ticket marking, photofinishing * Contains digits (0 to 9) and encodes the data only in the width of bars. */ class S25 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param bool $checksum */ public function __construct($code, $checksum = false) { $this->init($code, $checksum); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code * @param bool $checksum */ private function init($code, $checksum) { $chr = [ '0' => '10101110111010', '1' => '11101010101110', '2' => '10111010101110', '3' => '11101110101010', '4' => '10101110101110', '5' => '11101011101010', '6' => '10111011101010', '7' => '10101011101110', '8' => '10101110111010', '9' => '10111010111010', ]; $checkdigit = ''; if ($checksum) { // add checksum $checkdigit = $this->checksum($code); $code .= $checkdigit; } if ((strlen($code) % 2) != 0) { // add leading zero if code-length is odd $code = '0' . $code; } $seq = '11011010'; $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { $digit = $code[$i]; if (!isset($chr[$digit])) { // invalid character throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in S25 barcode value', $digit)); } $seq .= $chr[$digit]; } $seq .= '1101011'; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $bararray['checkdigit'] = $checkdigit; $this->data = $this->binseqToArray($seq, $bararray); } /** * Checksum for standard 2 of 5 barcodes. * * @param string $code * * @return int */ private function checksum($code) { $len = strlen($code); $sum = 0; for ($i = 0; $i < $len; $i += 2) { $sum += $code[$i]; } $sum *= 3; for ($i = 1; $i < $len; $i += 2) { $sum += ($code[$i]); } $r = $sum % 10; if ($r > 0) { $r = (10 - $r); } return $r; } /** * @inheritdoc */ public function getType() { return 'S25'; } } PK �2�\��ú3 3 Code128.phpnu &1i� <?php namespace Mpdf\Barcode; use Mpdf\Utils\UtfString; /** * C128 barcodes. * Very capable code, excellent density, high reliability; in very wide use world-wide */ class Code128 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param string $type * @param bool $ean */ public function __construct($code, $type = 'B', $ean = false) { $this->init($code, $type, $ean); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code * @param string $type * @param bool $ean */ protected function init($code, $type, $ean) { $code = UtfString::strcode2utf($code); // mPDF 5.7.1 Allows e.g. <barcode code="5432
1068" type="C128A" /> $chr = [ '212222', /* 00 */ '222122', /* 01 */ '222221', /* 02 */ '121223', /* 03 */ '121322', /* 04 */ '131222', /* 05 */ '122213', /* 06 */ '122312', /* 07 */ '132212', /* 08 */ '221213', /* 09 */ '221312', /* 10 */ '231212', /* 11 */ '112232', /* 12 */ '122132', /* 13 */ '122231', /* 14 */ '113222', /* 15 */ '123122', /* 16 */ '123221', /* 17 */ '223211', /* 18 */ '221132', /* 19 */ '221231', /* 20 */ '213212', /* 21 */ '223112', /* 22 */ '312131', /* 23 */ '311222', /* 24 */ '321122', /* 25 */ '321221', /* 26 */ '312212', /* 27 */ '322112', /* 28 */ '322211', /* 29 */ '212123', /* 30 */ '212321', /* 31 */ '232121', /* 32 */ '111323', /* 33 */ '131123', /* 34 */ '131321', /* 35 */ '112313', /* 36 */ '132113', /* 37 */ '132311', /* 38 */ '211313', /* 39 */ '231113', /* 40 */ '231311', /* 41 */ '112133', /* 42 */ '112331', /* 43 */ '132131', /* 44 */ '113123', /* 45 */ '113321', /* 46 */ '133121', /* 47 */ '313121', /* 48 */ '211331', /* 49 */ '231131', /* 50 */ '213113', /* 51 */ '213311', /* 52 */ '213131', /* 53 */ '311123', /* 54 */ '311321', /* 55 */ '331121', /* 56 */ '312113', /* 57 */ '312311', /* 58 */ '332111', /* 59 */ '314111', /* 60 */ '221411', /* 61 */ '431111', /* 62 */ '111224', /* 63 */ '111422', /* 64 */ '121124', /* 65 */ '121421', /* 66 */ '141122', /* 67 */ '141221', /* 68 */ '112214', /* 69 */ '112412', /* 70 */ '122114', /* 71 */ '122411', /* 72 */ '142112', /* 73 */ '142211', /* 74 */ '241211', /* 75 */ '221114', /* 76 */ '413111', /* 77 */ '241112', /* 78 */ '134111', /* 79 */ '111242', /* 80 */ '121142', /* 81 */ '121241', /* 82 */ '114212', /* 83 */ '124112', /* 84 */ '124211', /* 85 */ '411212', /* 86 */ '421112', /* 87 */ '421211', /* 88 */ '212141', /* 89 */ '214121', /* 90 */ '412121', /* 91 */ '111143', /* 92 */ '111341', /* 93 */ '131141', /* 94 */ '114113', /* 95 */ '114311', /* 96 */ '411113', /* 97 */ '411311', /* 98 */ '113141', /* 99 */ '114131', /* 100 */ '311141', /* 101 */ '411131', /* 102 */ '211412', /* 103 START A */ '211214', /* 104 START B */ '211232', /* 105 START C */ '233111', /* STOP */ '200000' /* END */ ]; switch (strtoupper($type)) { case 'A': $startid = 103; $keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'; for ($i = 0; $i < 32; ++$i) { $keys .= chr($i); } break; case 'B': $startid = 104; $keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127); break; case 'C': $startid = 105; $keys = ''; if ((strlen($code) % 2) != 0) { // The length of barcode value must be even ($code). You must pad the number with zeros throw new \Mpdf\Barcode\BarcodeException('Invalid CODE128C barcode value'); } for ($i = 0; $i <= 99; ++$i) { $keys .= chr($i); } $newCode = ''; $hclen = (strlen($code) / 2); for ($i = 0; $i < $hclen; ++$i) { $newCode .= chr((int) ($code{(2 * $i)} . $code{(2 * $i + 1)})); } $code = $newCode; break; default: throw new \Mpdf\Barcode\BarcodeException('Invalid CODE128 barcode type'); } // calculate check character $sum = $startid; // Add FNC 1 - which identifies it as EAN-128 if ($ean) { $code = chr(102) . $code; } $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { if ($ean && $i == 0) { $sum += 102; } else { $sum += (strpos($keys, $code[$i]) * ($i + 1)); } } $check = ($sum % 103); $checkdigit = $check; // add start, check and stop codes $code = chr($startid) . $code . chr($check) . chr(106) . chr(107); $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $k = 0; $len = strlen($code); for ($i = 0; $i < $len; ++$i) { $ck = strpos($keys, $code[$i]); if (($i == 0) || ($ean && $i == 1) | ($i > ($len - 4))) { $char_num = ord($code[$i]); $seq = $chr[$char_num]; } elseif (($ck >= 0) && isset($chr[$ck])) { $seq = $chr[$ck]; } else { // invalid character throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in CODE128C barcode value', $code[$i])); } for ($j = 0; $j < 6; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } $w = $seq[$j]; $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; } } $bararray['checkdigit'] = $checkdigit; $this->data = $bararray; } public function getType() { return 'CODE128'; } } PK �2�\�k� Postnet.phpnu &1i� <?php namespace Mpdf\Barcode; /** * POSTNET and PLANET barcodes. * Used by U.S. Postal Service for automated mail sorting */ class Postnet extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $xDim * @param float $gapWidth * @param bool $planet */ public function __construct($code, $xDim, $gapWidth, $planet = false) { $this->init($code, $gapWidth, $planet); $this->data['nom-X'] = $xDim; $this->data['nom-H'] = 3.175; // Nominal value for Height of Full bar in mm (spec.) $this->data['quietL'] = 3.175; // LEFT Quiet margin = mm (?spec.) $this->data['quietR'] = 3.175; // RIGHT Quiet margin = mm (?spec.) $this->data['quietTB'] = 1.016; // TOP/BOTTOM Quiet margin = mm (?spec.) } /** * @param string $code * @param float $gapWidth * @param bool $planet */ private function init($code, $gapWidth, $planet) { // bar lenght if ($planet) { $barlen = [ 0 => [1, 1, 2, 2, 2], 1 => [2, 2, 2, 1, 1], 2 => [2, 2, 1, 2, 1], 3 => [2, 2, 1, 1, 2], 4 => [2, 1, 2, 2, 1], 5 => [2, 1, 2, 1, 2], 6 => [2, 1, 1, 2, 2], 7 => [1, 2, 2, 2, 1], 8 => [1, 2, 2, 1, 2], 9 => [1, 2, 1, 2, 2] ]; } else { $barlen = [ 0 => [2, 2, 1, 1, 1], 1 => [1, 1, 1, 2, 2], 2 => [1, 1, 2, 1, 2], 3 => [1, 1, 2, 2, 1], 4 => [1, 2, 1, 1, 2], 5 => [1, 2, 1, 2, 1], 6 => [1, 2, 2, 1, 1], 7 => [2, 1, 1, 1, 2], 8 => [2, 1, 1, 2, 1], 9 => [2, 1, 2, 1, 1] ]; } $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 5, 'bcode' => []]; $k = 0; $code = str_replace('-', '', $code); $code = str_replace(' ', '', $code); $len = strlen($code); // calculate checksum $sum = 0; for ($i = 0; $i < $len; ++$i) { $sum += (int) $code[$i]; } $chkd = ($sum % 10); if ($chkd > 0) { $chkd = (10 - $chkd); } $code .= $chkd; $checkdigit = $chkd; $len = strlen($code); // start bar $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => 5, 'p' => 0]; $bararray['bcode'][$k++] = ['t' => 0, 'w' => $gapWidth, 'h' => 5, 'p' => 0]; $bararray['maxw'] += (1 + $gapWidth); for ($i = 0; $i < $len; ++$i) { for ($j = 0; $j < 5; ++$j) { $bh = $barlen[$code[$i]][$j]; if ($bh == 2) { $h = 5; $p = 0; } else { $h = 2; $p = 3; } $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => $h, 'p' => $p]; $bararray['bcode'][$k++] = ['t' => 0, 'w' => $gapWidth, 'h' => 2, 'p' => 0]; $bararray['maxw'] += (1 + $gapWidth); } } // end bar $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => 5, 'p' => 0]; $bararray['maxw'] += 1; $bararray['checkdigit'] = $checkdigit; $this->data = $bararray; } /** * @inheritdoc */ public function getType() { return 'POSTNET'; } } PK �2�\���gJ J BarcodeInterface.phpnu &1i� <?php namespace Mpdf\Barcode; interface BarcodeInterface { /** * @return string */ public function getType(); /** * @return mixed[] */ public function getData(); /** * @param string $key * * @return mixed */ public function getKey($key); /** * @return string */ public function getChecksum(); } PK �2�\sw�) ) Imb.phpnu &1i� <?php namespace Mpdf\Barcode; /** * IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 * * (requires PHP bcmath extension) * * Intelligent Mail barcode is a 65-bar code for use on mail in the United States. * The fields are described as follows: * * - The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently * printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This * shall be two digits, with the second digit in the range of 0-4. The allowable encoding ranges shall be 00-04, * 10-14, 20-24, 30-34, 40-44, 50-54, 60-64, 70-74, 80-84, and 90-94. * * - The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. * The allowable encoding range shall be 000-999. Each 3-digit value shall correspond to a particular mail class * with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, * shall provide the list of Service Type Identifier values. * * - The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies * a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the * allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999. * * - The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. * The allowable encoding range shall be 000000000-999999999 when used with a 6 digit Mailer ID and 000000-999999 * when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing * the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may * be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000-99999, 000000000-999999999, * and 00000000000-99999999999. */ class Imb extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $xDim * @param float $gapWidth * @param int[] $daft */ public function __construct($code, $xDim, $gapWidth, $daft) { if (!function_exists('bcadd')) { throw new \Mpdf\Barcode\BarcodeException('IMB barcodes require bcmath extension to be loaded.'); } $this->init($code, $gapWidth, $daft); $this->data['nom-X'] = $xDim; $this->data['nom-H'] = 3.68; // Nominal value for Height of Full bar in mm (spec.) // USPS-B-3200 Revision C = 4.623 // USPS-B-3200 Revision E = 3.68 $this->data['quietL'] = 3.175; // LEFT Quiet margin = mm (spec.) $this->data['quietR'] = 3.175; // RIGHT Quiet margin = mm (spec.) $this->data['quietTB'] = 0.711; // TOP/BOTTOM Quiet margin = mm (spec.) } /** * @param string $code * @param float $gapWidth * @param int[] $daft */ private function init($code, $gapWidth, $daft) { $asc_chr = [ 4, 0, 2, 6, 3, 5, 1, 9, 8, 7, 1, 2, 0, 6, 4, 8, 2, 9, 5, 3, 0, 1, 3, 7, 4, 6, 8, 9, 2, 0, 5, 1, 9, 4, 3, 8, 6, 7, 1, 2, 4, 3, 9, 5, 7, 8, 3, 0, 2, 1, 4, 0, 9, 1, 7, 0, 2, 4, 6, 3, 7, 1, 9, 5, 8 ]; $dsc_chr = [ 7, 1, 9, 5, 8, 0, 2, 4, 6, 3, 5, 8, 9, 7, 3, 0, 6, 1, 7, 4, 6, 8, 9, 2, 5, 1, 7, 5, 4, 3, 8, 7, 6, 0, 2, 5, 4, 9, 3, 0, 1, 6, 8, 2, 0, 4, 5, 9, 6, 7, 5, 2, 6, 3, 8, 5, 1, 9, 8, 7, 4, 0, 2, 6, 3 ]; $asc_pos = [ 3, 0, 8, 11, 1, 12, 8, 11, 10, 6, 4, 12, 2, 7, 9, 6, 7, 9, 2, 8, 4, 0, 12, 7, 10, 9, 0, 7, 10, 5, 7, 9, 6, 8, 2, 12, 1, 4, 2, 0, 1, 5, 4, 6, 12, 1, 0, 9, 4, 7, 5, 10, 2, 6, 9, 11, 2, 12, 6, 7, 5, 11, 0, 3, 2 ]; $dsc_pos = [ 2, 10, 12, 5, 9, 1, 5, 4, 3, 9, 11, 5, 10, 1, 6, 3, 4, 1, 10, 0, 2, 11, 8, 6, 1, 12, 3, 8, 6, 4, 4, 11, 0, 6, 1, 9, 11, 5, 3, 7, 3, 10, 7, 11, 8, 2, 10, 3, 5, 8, 0, 3, 12, 11, 8, 4, 5, 1, 3, 0, 7, 12, 9, 8, 10 ]; $codeArray = explode('-', $code); $trackingNumber = $codeArray[0]; $routingCode = ''; if (isset($codeArray[1])) { $routingCode = $codeArray[1]; } // Conversion of Routing Code switch (strlen($routingCode)) { case 0: $binaryCode = 0; break; case 5: $binaryCode = bcadd($routingCode, '1'); break; case 9: $binaryCode = bcadd($routingCode, '100001'); break; case 11: $binaryCode = bcadd($routingCode, '1000100001'); break; default: throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid MSI routing code "%s"', $routingCode)); } $binaryCode = bcmul($binaryCode, 10); $binaryCode = bcadd($binaryCode, $trackingNumber{0}); $binaryCode = bcmul($binaryCode, 5); $binaryCode = bcadd($binaryCode, $trackingNumber{1}); $binaryCode .= substr($trackingNumber, 2, 18); // convert to hexadecimal $binaryCode = $this->decToHex($binaryCode); // pad to get 13 bytes $binaryCode = str_pad($binaryCode, 26, '0', STR_PAD_LEFT); // convert string to array of bytes $binaryCodeArray = chunk_split($binaryCode, 2, "\r"); $binaryCodeArray = substr($binaryCodeArray, 0, -1); $binaryCodeArray = explode("\r", $binaryCodeArray); // calculate frame check sequence $fcs = $this->imbCrc11Fcs($binaryCodeArray); // exclude first 2 bits from first byte $first_byte = sprintf('%2s', dechex((hexdec($binaryCodeArray[0]) << 2) >> 2)); $binaryCode102bit = $first_byte . substr($binaryCode, 2); // convert binary data to codewords $codewords = []; $data = $this->hexToDec($binaryCode102bit); $codewords[0] = bcmod($data, 636) * 2; $data = bcdiv($data, 636); for ($i = 1; $i < 9; ++$i) { $codewords[$i] = bcmod($data, 1365); $data = bcdiv($data, 1365); } $codewords[9] = $data; if (($fcs >> 10) == 1) { $codewords[9] += 659; } // generate lookup tables $table2of13 = $this->imbTables(2, 78); $table5of13 = $this->imbTables(5, 1287); // convert codewords to characters $characters = []; $bitmask = 512; foreach ($codewords as $k => $val) { if ($val <= 1286) { $chrcode = $table5of13[$val]; } else { $chrcode = $table2of13[($val - 1287)]; } if (($fcs & $bitmask) > 0) { // bitwise invert $chrcode = ((~$chrcode) & 8191); } $characters[] = $chrcode; $bitmask /= 2; } $characters = array_reverse($characters); // build bars $k = 0; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => $daft['F'], 'bcode' => []]; for ($i = 0; $i < 65; ++$i) { $asc = (($characters[$asc_chr[$i]] & pow(2, $asc_pos[$i])) > 0); $dsc = (($characters[$dsc_chr[$i]] & pow(2, $dsc_pos[$i])) > 0); if ($asc and $dsc) { // full bar (F) $p = 0; $h = $daft['F']; } elseif ($asc) { // ascender (A) $p = 0; $h = $daft['A']; } elseif ($dsc) { // descender (D) $p = $daft['F'] - $daft['D']; $h = $daft['D']; } else { // tracker (T) $p = ($daft['F'] - $daft['T']) / 2; $h = $daft['T']; } $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => $h, 'p' => $p]; // Gap $bararray['bcode'][$k++] = ['t' => 0, 'w' => $gapWidth, 'h' => 1, 'p' => 0]; $bararray['maxw'] += (1 + $gapWidth); } unset($bararray['bcode'][($k - 1)]); $bararray['maxw'] -= $gapWidth; $this->data = $bararray; } /** * Intelligent Mail Barcode calculation of Frame Check Sequence * * @param string[] $codeArray * @return int */ private function imbCrc11Fcs($codeArray) { $genpoly = 0x0F35; // generator polynomial $fcs = 0x07FF; // Frame Check Sequence // do most significant byte skipping the 2 most significant bits $data = hexdec($codeArray[0]) << 5; for ($bit = 2; $bit < 8; ++$bit) { if (($fcs ^ $data) & 0x400) { $fcs = ($fcs << 1) ^ $genpoly; } else { $fcs = ($fcs << 1); } $fcs &= 0x7FF; $data <<= 1; } // do rest of bytes for ($byte = 1; $byte < 13; ++$byte) { $data = hexdec($codeArray[$byte]) << 3; for ($bit = 0; $bit < 8; ++$bit) { if (($fcs ^ $data) & 0x400) { $fcs = ($fcs << 1) ^ $genpoly; } else { $fcs = ($fcs << 1); } $fcs &= 0x7FF; $data <<= 1; } } return $fcs; } /** * Reverse unsigned short value * * @param int $num * @return int */ private function imbReverseUs($num) { $rev = 0; for ($i = 0; $i < 16; ++$i) { $rev <<= 1; $rev |= ($num & 1); $num >>= 1; } return $rev; } /** * Generate Nof13 tables used for Intelligent Mail Barcode * * @param int $n * @param int $size * * @return mixed[] */ private function imbTables($n, $size) { $table = []; $lli = 0; // LUT lower index $lui = $size - 1; // LUT upper index for ($count = 0; $count < 8192; ++$count) { $bitCount = 0; for ($bit_index = 0; $bit_index < 13; ++$bit_index) { $bitCount += (int) (($count & (1 << $bit_index)) != 0); } // if we don't have the right number of bits on, go on to the next value if ($bitCount == $n) { $reverse = ($this->imbReverseUs($count) >> 3); // if the reverse is less than count, we have already visited this pair before if ($reverse >= $count) { // If count is symmetric, place it at the first free slot from the end of the list. // Otherwise, place it at the first free slot from the beginning of the list AND place $reverse ath the next free slot from the beginning of the list if ($reverse == $count) { $table[$lui] = $count; --$lui; } else { $table[$lli] = $count; ++$lli; $table[$lli] = $reverse; ++$lli; } } } } return $table; } /** * Convert large integer number to hexadecimal representation. * * @param int $number * @return string */ private function decToHex($number) { $hex = []; if ($number == 0) { return '00'; } while ($number > 0) { if ($number == 0) { array_push($hex, '0'); } else { array_push($hex, strtoupper(dechex(bcmod($number, '16')))); $number = bcdiv($number, '16', 0); } } $hex = array_reverse($hex); return implode($hex); } /** * Convert large hexadecimal number to decimal representation (string). * (requires PHP bcmath extension) * * @param string $hex * @return int */ private function hexToDec($hex) { $dec = 0; $bitval = 1; $len = strlen($hex); for ($pos = ($len - 1); $pos >= 0; --$pos) { $dec = bcadd($dec, bcmul(hexdec($hex[$pos]), $bitval)); $bitval = bcmul($bitval, 16); } return $dec; } /** * @inheritdoc */ public function getType() { return 'IMB'; } } PK �2�\�HԵ EanExt.phpnu &1i� <?php namespace Mpdf\Barcode; /** * UPC-Based Extentions * 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers * 5-Digit Ext.: Used to mark suggested retail price of books */ class EanExt extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param int $length * @param float $leftMargin * @param float $rightMargin * @param float $xDim * @param float $barHeight * @param float $separatorMargin */ public function __construct($code, $length, $leftMargin, $rightMargin, $xDim, $barHeight, $separatorMargin) { $this->init($code, $length); $this->data['lightmL'] = $leftMargin; // LEFT light margin = x X-dim (http://www.gs1uk.org) $this->data['lightmR'] = $rightMargin; // RIGHT light margin = x X-dim (http://www.gs1uk.org) $this->data['nom-X'] = $xDim; // Nominal value for X-dim in mm (http://www.gs1uk.org) $this->data['nom-H'] = $barHeight; // Nominal bar height in mm incl. numerals (http://www.gs1uk.org) $this->data['sepM'] = $separatorMargin; // SEPARATION margin = x X-dim (http://web.archive.org/web/19990501035133/http://www.uc-council.org/d36-d.htm) } /** * @param string $code * @param int $length */ private function init($code, $length = 5) { // Padding $code = str_pad($code, $length, '0', STR_PAD_LEFT); // Calculate check digit if ($length == 2) { $r = $code % 4; } elseif ($length == 5) { $r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3})); $r %= 10; } else { throw new \Mpdf\Barcode\BarcodeException('Invalid EAN barcode value'); } // Convert digits to bars $codes = [ 'A' => [ // left odd parity '0' => '0001101', '1' => '0011001', '2' => '0010011', '3' => '0111101', '4' => '0100011', '5' => '0110001', '6' => '0101111', '7' => '0111011', '8' => '0110111', '9' => '0001011'], 'B' => [ // left even parity '0' => '0100111', '1' => '0110011', '2' => '0011011', '3' => '0100001', '4' => '0011101', '5' => '0111001', '6' => '0000101', '7' => '0010001', '8' => '0001001', '9' => '0010111'] ]; $parities = []; $parities[2] = [ '0' => ['A', 'A'], '1' => ['A', 'B'], '2' => ['B', 'A'], '3' => ['B', 'B'] ]; $parities[5] = [ '0' => ['B', 'B', 'A', 'A', 'A'], '1' => ['B', 'A', 'B', 'A', 'A'], '2' => ['B', 'A', 'A', 'B', 'A'], '3' => ['B', 'A', 'A', 'A', 'B'], '4' => ['A', 'B', 'B', 'A', 'A'], '5' => ['A', 'A', 'B', 'B', 'A'], '6' => ['A', 'A', 'A', 'B', 'B'], '7' => ['A', 'B', 'A', 'B', 'A'], '8' => ['A', 'B', 'A', 'A', 'B'], '9' => ['A', 'A', 'B', 'A', 'B'] ]; $p = $parities[$length][$r]; $seq = '1011'; // left guard bar $seq .= $codes[$p[0]][$code{0}]; for ($i = 1; $i < $length; ++$i) { $seq .= '01'; // separator $seq .= $codes[$p[$i]][$code[$i]]; } $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $this->data = $this->binseqToArray($seq, $bararray); } public function getType() { return 'EAN EXT'; } } PK �2�\t�mgX X BarcodeException.phpnu &1i� <?php namespace Mpdf\Barcode; class BarcodeException extends \Mpdf\MpdfException { } PK �2�\S�$� � EanUpc.phpnu &1i� <?php namespace Mpdf\Barcode; /** * EAN13 and UPC-A barcodes. * EAN13: European Article Numbering international retail product code * UPC-A: Universal product code seen on almost all retail products in the USA and Canada * UPC-E: Short version of UPC symbol */ class EanUpc extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param int $length * @param float $leftMargin * @param float $rightMargin * @param float $xDim * @param float $barHeight */ public function __construct($code, $length, $leftMargin, $rightMargin, $xDim, $barHeight) { $this->init($code, $length); $this->data['lightmL'] = $leftMargin; // LEFT light margin = x X-dim (http://www.gs1uk.org) $this->data['lightmR'] = $rightMargin; // RIGHT light margin = x X-dim (http://www.gs1uk.org) $this->data['nom-X'] = $xDim; // Nominal value for X-dim in mm (http://www.gs1uk.org) $this->data['nom-H'] = $barHeight; // Nominal bar height in mm incl. numerals (http://www.gs1uk.org) } /** * @param string $code * @param int $length */ private function init($code, $length) { $upce = false; $checkdigit = false; if ($length == 6) { $length = 12; // UPC-A $upce = true; // UPC-E mode } $dataLength = $length - 1; // Padding $code = str_pad($code, $dataLength, '0', STR_PAD_LEFT); $codeLength = strlen($code); // Calculate check digit $sum_a = 0; for ($i = 1; $i < $dataLength; $i += 2) { $sum_a += $code[$i]; } if ($length > 12) { $sum_a *= 3; } $sum_b = 0; for ($i = 0; $i < $dataLength; $i += 2) { $sum_b += ($code[$i]); } if ($length < 13) { $sum_b *= 3; } $r = ($sum_a + $sum_b) % 10; if ($r > 0) { $r = (10 - $r); } if ($codeLength == $dataLength) { // Add check digit $code .= $r; $checkdigit = $r; } elseif ($r !== (int) $code[$dataLength]) { // Wrong checkdigit throw new \Mpdf\Barcode\BarcodeException('Invalid EAN UPC barcode value'); } if ($length == 12) { // UPC-A $code = '0' . $code; ++$length; } if ($upce) { // Convert UPC-A to UPC-E $tmp = substr($code, 4, 3); $prodCode = (int) substr($code, 7, 5); // product code $invalidUpce = false; if (($tmp == '000') or ($tmp == '100') or ($tmp == '200')) { // Manufacturer code ends in 000, 100, or 200 $upceCode = substr($code, 2, 2) . substr($code, 9, 3) . substr($code, 4, 1); if ($prodCode > 999) { $invalidUpce = true; } } else { $tmp = substr($code, 5, 2); if ($tmp == '00') { // Manufacturer code ends in 00 $upceCode = substr($code, 2, 3) . substr($code, 10, 2) . '3'; if ($prodCode > 99) { $invalidUpce = true; } } else { $tmp = substr($code, 6, 1); if ($tmp == '0') { // Manufacturer code ends in 0 $upceCode = substr($code, 2, 4) . substr($code, 11, 1) . '4'; if ($prodCode > 9) { $invalidUpce = true; } } else { // Manufacturer code does not end in zero $upceCode = substr($code, 2, 5) . substr($code, 11, 1); if ($prodCode > 9) { $invalidUpce = true; } } } } if ($invalidUpce) { throw new \Mpdf\Barcode\BarcodeException('UPC-A cannot produce a valid UPC-E barcode'); } } // Convert digits to bars $codes = [ 'A' => [// left odd parity '0' => '0001101', '1' => '0011001', '2' => '0010011', '3' => '0111101', '4' => '0100011', '5' => '0110001', '6' => '0101111', '7' => '0111011', '8' => '0110111', '9' => '0001011'], 'B' => [// left even parity '0' => '0100111', '1' => '0110011', '2' => '0011011', '3' => '0100001', '4' => '0011101', '5' => '0111001', '6' => '0000101', '7' => '0010001', '8' => '0001001', '9' => '0010111'], 'C' => [// right '0' => '1110010', '1' => '1100110', '2' => '1101100', '3' => '1000010', '4' => '1011100', '5' => '1001110', '6' => '1010000', '7' => '1000100', '8' => '1001000', '9' => '1110100'] ]; $parities = [ '0' => ['A', 'A', 'A', 'A', 'A', 'A'], '1' => ['A', 'A', 'B', 'A', 'B', 'B'], '2' => ['A', 'A', 'B', 'B', 'A', 'B'], '3' => ['A', 'A', 'B', 'B', 'B', 'A'], '4' => ['A', 'B', 'A', 'A', 'B', 'B'], '5' => ['A', 'B', 'B', 'A', 'A', 'B'], '6' => ['A', 'B', 'B', 'B', 'A', 'A'], '7' => ['A', 'B', 'A', 'B', 'A', 'B'], '8' => ['A', 'B', 'A', 'B', 'B', 'A'], '9' => ['A', 'B', 'B', 'A', 'B', 'A'] ]; $upceParities = []; $upceParities[0] = [ '0' => ['B', 'B', 'B', 'A', 'A', 'A'], '1' => ['B', 'B', 'A', 'B', 'A', 'A'], '2' => ['B', 'B', 'A', 'A', 'B', 'A'], '3' => ['B', 'B', 'A', 'A', 'A', 'B'], '4' => ['B', 'A', 'B', 'B', 'A', 'A'], '5' => ['B', 'A', 'A', 'B', 'B', 'A'], '6' => ['B', 'A', 'A', 'A', 'B', 'B'], '7' => ['B', 'A', 'B', 'A', 'B', 'A'], '8' => ['B', 'A', 'B', 'A', 'A', 'B'], '9' => ['B', 'A', 'A', 'B', 'A', 'B'] ]; $upceParities[1] = [ '0' => ['A', 'A', 'A', 'B', 'B', 'B'], '1' => ['A', 'A', 'B', 'A', 'B', 'B'], '2' => ['A', 'A', 'B', 'B', 'A', 'B'], '3' => ['A', 'A', 'B', 'B', 'B', 'A'], '4' => ['A', 'B', 'A', 'A', 'B', 'B'], '5' => ['A', 'B', 'B', 'A', 'A', 'B'], '6' => ['A', 'B', 'B', 'B', 'A', 'A'], '7' => ['A', 'B', 'A', 'B', 'A', 'B'], '8' => ['A', 'B', 'A', 'B', 'B', 'A'], '9' => ['A', 'B', 'B', 'A', 'B', 'A'] ]; $k = 0; $seq = '101'; // left guard bar if ($upce && isset($upceCode)) { $bararray = ['code' => $upceCode, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $p = $upceParities[$code{1}][$r]; for ($i = 0; $i < 6; ++$i) { $seq .= $codes[$p[$i]][$upceCode[$i]]; } $seq .= '010101'; // right guard bar } else { $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $halfLen = ceil($length / 2); if ($length == 8) { for ($i = 0; $i < $halfLen; ++$i) { $seq .= $codes['A'][$code[$i]]; } } else { $p = $parities[$code{0}]; for ($i = 1; $i < $halfLen; ++$i) { $seq .= $codes[$p[$i - 1]][$code[$i]]; } } $seq .= '01010'; // center guard bar for ($i = $halfLen; $i < $length; ++$i) { $seq .= $codes['C'][$code[(int) $i]]; } $seq .= '101'; // right guard bar } $clen = strlen($seq); $w = 0; for ($i = 0; $i < $clen; ++$i) { $w += 1; if (($i == ($clen - 1)) or (($i < ($clen - 1)) and ($seq[$i] != $seq[($i + 1)]))) { if ($seq[$i] == '1') { $t = true; // bar } else { $t = false; // space } $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; $w = 0; } } $bararray['checkdigit'] = $checkdigit; $this->data = $bararray; } /** * @inheritdoc */ public function getType() { return 'EANUPC'; } } PK �2�\#8�h Code39.phpnu &1i� <?php namespace Mpdf\Barcode; /** * CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. */ class Code39 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $printRatio * @param bool $extended * @param bool $checksum */ public function __construct($code, $printRatio, $extended = false, $checksum = false) { $this->init($code, $printRatio, $extended, $checksum); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code * @param float $printRatio * @param bool $extended * @param bool $checksum * * @return mixed[] */ private function init($code, $printRatio, $extended, $checksum) { $chr = [ '0' => '111221211', '1' => '211211112', '2' => '112211112', '3' => '212211111', '4' => '111221112', '5' => '211221111', '6' => '112221111', '7' => '111211212', '8' => '211211211', '9' => '112211211', 'A' => '211112112', 'B' => '112112112', 'C' => '212112111', 'D' => '111122112', 'E' => '211122111', 'F' => '112122111', 'G' => '111112212', 'H' => '211112211', 'I' => '112112211', 'J' => '111122211', 'K' => '211111122', 'L' => '112111122', 'M' => '212111121', 'N' => '111121122', 'O' => '211121121', 'P' => '112121121', 'Q' => '111111222', 'R' => '211111221', 'S' => '112111221', 'T' => '111121221', 'U' => '221111112', 'V' => '122111112', 'W' => '222111111', 'X' => '121121112', 'Y' => '221121111', 'Z' => '122121111', '-' => '121111212', '.' => '221111211', ' ' => '122111211', '$' => '121212111', '/' => '121211121', '+' => '121112121', '%' => '111212121', '*' => '121121211', ]; $code = strtoupper($code); $checkdigit = ''; if ($extended) { // extended mode $code = $this->encodeExt($code); } if ($code === false) { throw new \Mpdf\Barcode\BarcodeException('Invalid CODE39 barcode value'); } if ($checksum) { // checksum $checkdigit = $this->checksum($code); $code .= $checkdigit; } // add star$this->>datat and stop codes $code = '*' . $code . '*'; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $k = 0; $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { $char = $code[$i]; if (!isset($chr[$char])) { // invalid character throw new \Mpdf\Barcode\BarcodeException('Invalid CODE39 barcode value'); } for ($j = 0; $j < 9; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } $x = $chr[$char][$j]; if ($x == 2) { $w = $printRatio; } else { $w = 1; } $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; } $bararray['bcode'][$k] = ['t' => false, 'w' => 1, 'h' => 1, 'p' => 0]; $bararray['maxw'] += 1; ++$k; } $bararray['checkdigit'] = $checkdigit; $this->data = $bararray; } /** * Encode a string to be used for CODE 39 Extended mode. * * @param string $code * @return string */ protected function encodeExt($code) { $encode = [ chr(0) => '%U', chr(1) => '$A', chr(2) => '$B', chr(3) => '$C', chr(4) => '$D', chr(5) => '$E', chr(6) => '$F', chr(7) => '$G', chr(8) => '$H', chr(9) => '$I', chr(10) => '$J', chr(11) => '£K', chr(12) => '$L', chr(13) => '$M', chr(14) => '$N', chr(15) => '$O', chr(16) => '$P', chr(17) => '$Q', chr(18) => '$R', chr(19) => '$S', chr(20) => '$T', chr(21) => '$U', chr(22) => '$V', chr(23) => '$W', chr(24) => '$X', chr(25) => '$Y', chr(26) => '$Z', chr(27) => '%A', chr(28) => '%B', chr(29) => '%C', chr(30) => '%D', chr(31) => '%E', chr(32) => ' ', chr(33) => '/A', chr(34) => '/B', chr(35) => '/C', chr(36) => '/D', chr(37) => '/E', chr(38) => '/F', chr(39) => '/G', chr(40) => '/H', chr(41) => '/I', chr(42) => '/J', chr(43) => '/K', chr(44) => '/L', chr(45) => '-', chr(46) => '.', chr(47) => '/O', chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3', chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7', chr(56) => '8', chr(57) => '9', chr(58) => '/Z', chr(59) => '%F', chr(60) => '%G', chr(61) => '%H', chr(62) => '%I', chr(63) => '%J', chr(64) => '%V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C', chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G', chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K', chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O', chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S', chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W', chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => '%K', chr(92) => '%L', chr(93) => '%M', chr(94) => '%N', chr(95) => '%O', chr(96) => '%W', chr(97) => '+A', chr(98) => '+B', chr(99) => '+C', chr(100) => '+D', chr(101) => '+E', chr(102) => '+F', chr(103) => '+G', chr(104) => '+H', chr(105) => '+I', chr(106) => '+J', chr(107) => '+K', chr(108) => '+L', chr(109) => '+M', chr(110) => '+N', chr(111) => '+O', chr(112) => '+P', chr(113) => '+Q', chr(114) => '+R', chr(115) => '+S', chr(116) => '+T', chr(117) => '+U', chr(118) => '+V', chr(119) => '+W', chr(120) => '+X', chr(121) => '+Y', chr(122) => '+Z', chr(123) => '%P', chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T' ]; $code_ext = ''; $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { if (ord($code[$i]) > 127) { throw new \Mpdf\Barcode\BarcodeException('Invalid CODE39 barcode value'); } $code_ext .= $encode[$code[$i]]; } return $code_ext; } /** * Calculate CODE 39 checksum (modulo 43). * * @param string $code * @return string mixed */ protected function checksum($code) { $chars = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%' ]; $sum = 0; $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { $k = array_keys($chars, $code[$i]); $sum += $k[0]; } $j = ($sum % 43); return $chars[$j]; } /** * @inheritdoc */ public function getType() { return 'CODE39'; } } PK �2�\��1h h Code93.phpnu &1i� <?php namespace Mpdf\Barcode; /** * CODE 93 - USS-93 * Compact code similar to Code 39 */ class Code93 extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code */ public function __construct($code) { $this->init($code); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code */ private function init($code) { $chr = [ 48 => '131112', // 0 49 => '111213', // 1 50 => '111312', // 2 51 => '111411', // 3 52 => '121113', // 4 53 => '121212', // 5 54 => '121311', // 6 55 => '111114', // 7 56 => '131211', // 8 57 => '141111', // 9 65 => '211113', // A 66 => '211212', // B 67 => '211311', // C 68 => '221112', // D 69 => '221211', // E 70 => '231111', // F 71 => '112113', // G 72 => '112212', // H 73 => '112311', // I 74 => '122112', // J 75 => '132111', // K 76 => '111123', // L 77 => '111222', // M 78 => '111321', // N 79 => '121122', // O 80 => '131121', // P 81 => '212112', // Q 82 => '212211', // R 83 => '211122', // S 84 => '211221', // T 85 => '221121', // U 86 => '222111', // V 87 => '112122', // W 88 => '112221', // X 89 => '122121', // Y 90 => '123111', // Z 45 => '121131', // - 46 => '311112', // . 32 => '311211', // 36 => '321111', // $ 47 => '112131', // / 43 => '113121', // + 37 => '211131', // % 128 => '121221', // ($) 129 => '311121', // (/) 130 => '122211', // (+) 131 => '312111', // (%) 42 => '111141', // start-stop ]; $code = strtoupper($code); $encode = [ chr(0) => chr(131) . 'U', chr(1) => chr(128) . 'A', chr(2) => chr(128) . 'B', chr(3) => chr(128) . 'C', chr(4) => chr(128) . 'D', chr(5) => chr(128) . 'E', chr(6) => chr(128) . 'F', chr(7) => chr(128) . 'G', chr(8) => chr(128) . 'H', chr(9) => chr(128) . 'I', chr(10) => chr(128) . 'J', chr(11) => '£K', chr(12) => chr(128) . 'L', chr(13) => chr(128) . 'M', chr(14) => chr(128) . 'N', chr(15) => chr(128) . 'O', chr(16) => chr(128) . 'P', chr(17) => chr(128) . 'Q', chr(18) => chr(128) . 'R', chr(19) => chr(128) . 'S', chr(20) => chr(128) . 'T', chr(21) => chr(128) . 'U', chr(22) => chr(128) . 'V', chr(23) => chr(128) . 'W', chr(24) => chr(128) . 'X', chr(25) => chr(128) . 'Y', chr(26) => chr(128) . 'Z', chr(27) => chr(131) . 'A', chr(28) => chr(131) . 'B', chr(29) => chr(131) . 'C', chr(30) => chr(131) . 'D', chr(31) => chr(131) . 'E', chr(32) => ' ', chr(33) => chr(129) . 'A', chr(34) => chr(129) . 'B', chr(35) => chr(129) . 'C', chr(36) => chr(129) . 'D', chr(37) => chr(129) . 'E', chr(38) => chr(129) . 'F', chr(39) => chr(129) . 'G', chr(40) => chr(129) . 'H', chr(41) => chr(129) . 'I', chr(42) => chr(129) . 'J', chr(43) => chr(129) . 'K', chr(44) => chr(129) . 'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129) . 'O', chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3', chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7', chr(56) => '8', chr(57) => '9', chr(58) => chr(129) . 'Z', chr(59) => chr(131) . 'F', chr(60) => chr(131) . 'G', chr(61) => chr(131) . 'H', chr(62) => chr(131) . 'I', chr(63) => chr(131) . 'J', chr(64) => chr(131) . 'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C', chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G', chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K', chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O', chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S', chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W', chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131) . 'K', chr(92) => chr(131) . 'L', chr(93) => chr(131) . 'M', chr(94) => chr(131) . 'N', chr(95) => chr(131) . 'O', chr(96) => chr(131) . 'W', chr(97) => chr(130) . 'A', chr(98) => chr(130) . 'B', chr(99) => chr(130) . 'C', chr(100) => chr(130) . 'D', chr(101) => chr(130) . 'E', chr(102) => chr(130) . 'F', chr(103) => chr(130) . 'G', chr(104) => chr(130) . 'H', chr(105) => chr(130) . 'I', chr(106) => chr(130) . 'J', chr(107) => chr(130) . 'K', chr(108) => chr(130) . 'L', chr(109) => chr(130) . 'M', chr(110) => chr(130) . 'N', chr(111) => chr(130) . 'O', chr(112) => chr(130) . 'P', chr(113) => chr(130) . 'Q', chr(114) => chr(130) . 'R', chr(115) => chr(130) . 'S', chr(116) => chr(130) . 'T', chr(117) => chr(130) . 'U', chr(118) => chr(130) . 'V', chr(119) => chr(130) . 'W', chr(120) => chr(130) . 'X', chr(121) => chr(130) . 'Y', chr(122) => chr(130) . 'Z', chr(123) => chr(131) . 'P', chr(124) => chr(131) . 'Q', chr(125) => chr(131) . 'R', chr(126) => chr(131) . 'S', chr(127) => chr(131) . 'T' ]; $code_ext = ''; $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { if (ord($code{$i}) > 127) { throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" in Code93 barcode value', $code{$i})); } $code_ext .= $encode[$code{$i}]; } // checksum $code_ext .= $this->checksum($code_ext); // add start and stop codes $code = '*' . $code_ext . '*'; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $k = 0; $clen = strlen($code); for ($i = 0; $i < $clen; ++$i) { $char = ord($code{$i}); if (!isset($chr[$char])) { // invalid character throw new \Mpdf\Barcode\BarcodeException('Invalid CODE93 barcode value'); } for ($j = 0; $j < 6; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } $w = $chr[$char]{$j}; $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; } } $bararray['bcode'][$k] = ['t' => true, 'w' => 1, 'h' => 1, 'p' => 0]; $bararray['maxw'] += 1; $this->data = $bararray; } /** * Calculate CODE 93 checksum (modulo 47). * * @param string $code * @return string */ protected function checksum($code) { $chars = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%', '<', '=', '>', '?' ]; // translate special characters $code = strtr($code, chr(128) . chr(131) . chr(129) . chr(130), '<=>?'); $len = strlen($code); // calculate check digit C $p = 1; $check = 0; for ($i = ($len - 1); $i >= 0; --$i) { $k = array_keys($chars, $code{$i}); $check += ($k[0] * $p); ++$p; if ($p > 20) { $p = 1; } } $check %= 47; $c = $chars[$check]; $code .= $c; // calculate check digit K $p = 1; $check = 0; for ($i = $len; $i >= 0; --$i) { $k = array_keys($chars, $code{$i}); $check += ($k[0] * $p); ++$p; if ($p > 15) { $p = 1; } } $check %= 47; $k = $chars[$check]; $checksum = $c . $k; // resto respecial characters $checksum = strtr($checksum, '<=>?', chr(128) . chr(131) . chr(129) . chr(130)); return $checksum; } /** * @inheritdoc */ public function getType() { return 'CODE93'; } } PK �2�\�$��T T Codabar.phpnu &1i� <?php namespace Mpdf\Barcode; /** * CODABAR barcodes. * Older code often used in library systems, sometimes in blood banks */ class Codabar extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $printRatio */ public function __construct($code, $printRatio) { $this->init($code, $printRatio); $this->data['nom-X'] = 0.381; // Nominal value for X-dim (bar width) in mm (2 X min. spec.) $this->data['nom-H'] = 10; // Nominal value for Height of Full bar in mm (non-spec.) $this->data['lightmL'] = 10; // LEFT light margin = x X-dim (spec.) $this->data['lightmR'] = 10; // RIGHT light margin = x X-dim (spec.) $this->data['lightTB'] = 0; // TOP/BOTTOM light margin = x X-dim (non-spec.) } /** * @param string $code * @param float $printRatio */ private function init($code, $printRatio) { $chr = [ '0' => '11111221', '1' => '11112211', '2' => '11121121', '3' => '22111111', '4' => '11211211', '5' => '21111211', '6' => '12111121', '7' => '12112111', '8' => '12211111', '9' => '21121111', '-' => '11122111', '$' => '11221111', ':' => '21112121', '/' => '21211121', '.' => '21212111', '+' => '11222221', 'A' => '11221211', 'B' => '12121121', 'C' => '11121221', 'D' => '11122211' ]; $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => []]; $k = 0; $code = strtoupper($code); $len = strlen($code); for ($i = 0; $i < $len; ++$i) { if (!isset($chr[$code[$i]])) { throw new \Mpdf\Barcode\BarcodeException(sprintf('Invalid character "%s" CODABAR barcode value', $code[$i])); } $seq = $chr[$code[$i]]; for ($j = 0; $j < 8; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } $x = $seq[$j]; if ($x == 2) { $w = $printRatio; } else { $w = 1; } $bararray['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0]; $bararray['maxw'] += $w; ++$k; } } $this->data = $bararray; } public function getType() { return 'CODABAR'; } } PK �2�\�1x�� � Rm4Scc.phpnu &1i� <?php namespace Mpdf\Barcode; class Rm4Scc extends \Mpdf\Barcode\AbstractBarcode implements \Mpdf\Barcode\BarcodeInterface { /** * @param string $code * @param float $xDim * @param float $gapWidth * @param int[] $daft * @param bool $kix */ public function __construct($code, $xDim, $gapWidth, $daft, $kix = false) { $this->init($code, $gapWidth, $daft, $kix); $this->data['nom-X'] = $xDim; $this->data['nom-H'] = 5.0; // Nominal value for Height of Full bar in mm (spec.) $this->data['quietL'] = 2; // LEFT Quiet margin = mm (spec.) $this->data['quietR'] = 2; // RIGHT Quiet margin = mm (spec.) $this->data['quietTB'] = 2; // TOP/BOTTOM Quiet margin = mm (spec?) } /** * @param string $code * @param float $gapWidth * @param int[] $daft * @param bool $kix */ private function init($code, $gapWidth, $daft, $kix) { $notkix = !$kix; // bar mode // 1 = pos 1, length 2 // 2 = pos 1, length 3 // 3 = pos 2, length 1 // 4 = pos 2, length 2 $barmode = [ '0' => [3, 3, 2, 2], '1' => [3, 4, 1, 2], '2' => [3, 4, 2, 1], '3' => [4, 3, 1, 2], '4' => [4, 3, 2, 1], '5' => [4, 4, 1, 1], '6' => [3, 1, 4, 2], '7' => [3, 2, 3, 2], '8' => [3, 2, 4, 1], '9' => [4, 1, 3, 2], 'A' => [4, 1, 4, 1], 'B' => [4, 2, 3, 1], 'C' => [3, 1, 2, 4], 'D' => [3, 2, 1, 4], 'E' => [3, 2, 2, 3], 'F' => [4, 1, 1, 4], 'G' => [4, 1, 2, 3], 'H' => [4, 2, 1, 3], 'I' => [1, 3, 4, 2], 'J' => [1, 4, 3, 2], 'K' => [1, 4, 4, 1], 'L' => [2, 3, 3, 2], 'M' => [2, 3, 4, 1], 'N' => [2, 4, 3, 1], 'O' => [1, 3, 2, 4], 'P' => [1, 4, 1, 4], 'Q' => [1, 4, 2, 3], 'R' => [2, 3, 1, 4], 'S' => [2, 3, 2, 3], 'T' => [2, 4, 1, 3], 'U' => [1, 1, 4, 4], 'V' => [1, 2, 3, 4], 'W' => [1, 2, 4, 3], 'X' => [2, 1, 3, 4], 'Y' => [2, 1, 4, 3], 'Z' => [2, 2, 3, 3] ]; $code = strtoupper($code); $len = strlen($code); $bararray = ['code' => $code, 'maxw' => 0, 'maxh' => $daft['F'], 'bcode' => []]; if ($notkix) { // table for checksum calculation (row,col) $checktable = [ '0' => [1, 1], '1' => [1, 2], '2' => [1, 3], '3' => [1, 4], '4' => [1, 5], '5' => [1, 0], '6' => [2, 1], '7' => [2, 2], '8' => [2, 3], '9' => [2, 4], 'A' => [2, 5], 'B' => [2, 0], 'C' => [3, 1], 'D' => [3, 2], 'E' => [3, 3], 'F' => [3, 4], 'G' => [3, 5], 'H' => [3, 0], 'I' => [4, 1], 'J' => [4, 2], 'K' => [4, 3], 'L' => [4, 4], 'M' => [4, 5], 'N' => [4, 0], 'O' => [5, 1], 'P' => [5, 2], 'Q' => [5, 3], 'R' => [5, 4], 'S' => [5, 5], 'T' => [5, 0], 'U' => [0, 1], 'V' => [0, 2], 'W' => [0, 3], 'X' => [0, 4], 'Y' => [0, 5], 'Z' => [0, 0] ]; $row = 0; $col = 0; for ($i = 0; $i < $len; ++$i) { $row += $checktable[$code[$i]][0]; $col += $checktable[$code[$i]][1]; } $row %= 6; $col %= 6; $chk = array_keys($checktable, [$row, $col]); $code .= $chk[0]; $bararray['checkdigit'] = $chk[0]; ++$len; } $k = 0; if ($notkix) { // start bar $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => $daft['A'], 'p' => 0]; $bararray['bcode'][$k++] = ['t' => 0, 'w' => $gapWidth, 'h' => $daft['A'], 'p' => 0]; $bararray['maxw'] += (1 + $gapWidth); } for ($i = 0; $i < $len; ++$i) { for ($j = 0; $j < 4; ++$j) { switch ($barmode[$code[$i]][$j]) { case 1: // ascender (A) $p = 0; $h = $daft['A']; break; case 2: // full bar (F) $p = 0; $h = $daft['F']; break; case 3: // tracker (T) $p = ($daft['F'] - $daft['T']) / 2; $h = $daft['T']; break; case 4: // descender (D) $p = $daft['F'] - $daft['D']; $h = $daft['D']; break; } $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => $h, 'p' => $p]; $bararray['bcode'][$k++] = ['t' => 0, 'w' => $gapWidth, 'h' => 2, 'p' => 0]; $bararray['maxw'] += (1 + $gapWidth); } } if ($notkix) { // stop bar $bararray['bcode'][$k++] = ['t' => 1, 'w' => 1, 'h' => $daft['F'], 'p' => 0]; $bararray['maxw'] += 1; } $this->data = $bararray; } /** * @inheritdoc */ public function getType() { return 'RM4SCC'; } } PK �2�\�� X Msi.phpnu &1i� PK �2�\@��X X M I25.phpnu &1i� PK �2�\q�@� � � Code11.phpnu &1i� PK �2�\lm�HO O � AbstractBarcode.phpnu &1i� PK �2�\5-�C� � y% S25.phpnu &1i� PK �2�\��ú3 3 H/ Code128.phpnu &1i� PK �2�\�k� �F Postnet.phpnu &1i� PK �2�\���gJ J R BarcodeInterface.phpnu &1i� PK �2�\sw�) ) �S Imb.phpnu &1i� PK �2�\�HԵ �| EanExt.phpnu &1i� PK �2�\t�mgX X ?� BarcodeException.phpnu &1i� PK �2�\S�$� � ۉ EanUpc.phpnu &1i� PK �2�\#8�h ֤ Code39.phpnu &1i� PK �2�\��1h h (� Code93.phpnu &1i� PK �2�\�$��T T �� Codabar.phpnu &1i� PK �2�\�1x�� � Y� Rm4Scc.phpnu &1i� PK � p�
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings