diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index b97da56..340d7ed 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +4.5.039 (2009-04-11) + - Support for linear barcodes was extended (see example n. 27 and barcodes.php documentation). + 4.5.038 (2009-04-10) - Write() method was improved to support separators for Japanese, Korean, Chinese Traditional and Chinese Simplified. diff --git a/README.TXT b/README.TXT index 44ae31c..2af942f 100755 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 4.5.038 -Release date: 2009-04-10 +Version: 4.5.039 +Release date: 2009-04-11 Author: Nicola Asuni Copyright (c) 2001-2009: diff --git a/barcodes.php b/barcodes.php index 0d3886a..1997d6e 100755 --- a/barcodes.php +++ b/barcodes.php @@ -2,8 +2,8 @@ //============================================================+ // File name : barcodes.php // Begin : 2008-06-09 -// Last Update : 2009-02-13 -// Version : 1.0.005 +// Last Update : 2009-04-11 +// Version : 1.0.006 // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html) // ---------------------------------------------------------------------------- // Copyright (C) 2008-2009 Nicola Asuni - Tecnick.com S.r.l. @@ -47,14 +47,14 @@ * @copyright 2008-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @link http://www.tcpdf.org * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version 1.0.005 + * @version 1.0.006 */ /** * PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).
* @name TCPDFBarcode * @package com.tecnick.tcpdf - * @version 1.0.005 + * @version 1.0.006 * @author Nicola Asuni * @link http://www.tcpdf.org * @license http://www.gnu.org/copyleft/lesser.html LGPL @@ -79,7 +79,7 @@ class TCPDFBarcode { *
  • $arrcode['bcode'][$k]['h'] bar height in units.
  • *
  • $arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)
  • * @param string $code code to print - * @param string $type type of barcode: + * @param string $type type of barcode: */ public function __construct($code, $type) { $this->setBarcode($code, $type); @@ -96,12 +96,12 @@ class TCPDFBarcode { /** * Set the barcode. * @param string $code code to print - * @param string $type type of barcode: + * @param string $type type of barcode: * @return array */ public function setBarcode($code, $type) { switch (strtoupper($type)) { - case 'C39': { // CODE 39 + case 'C39': { // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. $arrcode = $this->barcode_code39($code, false, false); break; } @@ -113,12 +113,28 @@ class TCPDFBarcode { $arrcode = $this->barcode_code39($code, true, false); break; } - case 'C39E+': { // CODE 39 EXTENDED with checksum + case 'C39E+': { // CODE 39 EXTENDED + CHECKSUM $arrcode = $this->barcode_code39($code, true, true); break; + } + case 'C93': { // CODE 93 - USS-93 + $arrcode = $this->barcode_code93($code); + break; + } + case 'S25': { // Standard 2 of 5 + $arrcode = $this->barcode_s25($code, false); + break; + } + case 'S25+': { // Standard 2 of 5 + CHECKSUM + $arrcode = $this->barcode_s25($code, true); + break; } case 'I25': { // Interleaved 2 of 5 - $arrcode = $this->barcode_i25($code); + $arrcode = $this->barcode_i25($code, false); + break; + } + case 'I25+': { // Interleaved 2 of 5 + CHECKSUM + $arrcode = $this->barcode_i25($code, true); break; } case 'C128A': { // CODE 128 A @@ -132,22 +148,70 @@ class TCPDFBarcode { case 'C128C': { // CODE 128 C $arrcode = $this->barcode_c128($code, 'C'); break; + } + case 'EAN2': { // 2-Digits UPC-Based Extention + $arrcode = $this->barcode_eanext($code, 2); + break; + } + case 'EAN5': { // 5-Digits UPC-Based Extention + $arrcode = $this->barcode_eanext($code, 5); + break; + } + case 'EAN8': { // EAN 8 + $arrcode = $this->barcode_eanupc($code, 8); + break; } case 'EAN13': { // EAN 13 - $arrcode = $this->barcode_ean13($code, 13); + $arrcode = $this->barcode_eanupc($code, 13); break; } case 'UPCA': { // UPC-A - $arrcode = $this->barcode_ean13($code, 12); + $arrcode = $this->barcode_eanupc($code, 12); + break; + } + case 'UPCE': { // UPC-E + $arrcode = $this->barcode_eanupc($code, 6); + break; + } + case 'MSI': { // MSI (Variation of Plessey code) + $arrcode = $this->barcode_msi($code, false); + break; + } + case 'MSI+': { // MSI + CHECKSUM (modulo 11) + $arrcode = $this->barcode_msi($code, true); break; } case 'POSTNET': { // POSTNET - $arrcode = $this->barcode_postnet($code); + $arrcode = $this->barcode_postnet($code, false); break; - } + } + case 'PLANET': { // PLANET + $arrcode = $this->barcode_postnet($code, true); + break; + } + case 'RMS4CC': { // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) + $arrcode = $this->barcode_rms4cc($code, false); + break; + } + case 'KIX': { // KIX (Klant index - Customer index) + $arrcode = $this->barcode_rms4cc($code, true); + break; + } case 'CODABAR': { // CODABAR $arrcode = $this->barcode_codabar($code); break; + } + case 'CODE11': { // CODE 11 + $arrcode = $this->barcode_code11($code); + break; + } + case 'PHARMA': { // PHARMACODE + $arrcode = $this->barcode_pharmacode($code); + break; + } + case 'PHARMA2T': { // PHARMACODE TWO-TRACKS + $arrcode = $this->barcode_pharmacode2t($code); + break; } default: { $this->barcode_array = false; @@ -157,7 +221,8 @@ class TCPDFBarcode { } /** - * CODE 39 + * CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. + * General-purpose code in very wide use world-wide * @param string $code code to represent. * @param boolean $checksum if true add a checksum to the code * @return array barcode representation. @@ -203,11 +268,11 @@ class TCPDFBarcode { $chr['-'] = '121111212'; $chr['.'] = '221111211'; $chr[' '] = '122111211'; - $chr['*'] = '121121211'; $chr['$'] = '121212111'; $chr['/'] = '121211121'; $chr['+'] = '121112121'; - $chr['%'] = '111212121'; + $chr['%'] = '111212121'; + $chr['*'] = '121121211'; $code = strtoupper($code); if ($extended) { @@ -225,14 +290,15 @@ class TCPDFBarcode { $code = '*'.$code.'*'; $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - $k = 0; - for($i=0; $i < strlen($code); $i++) { + $k = 0; + $clen = strlen($code); + for ($i = 0; $i < $clen; ++$i) { $char = $code{$i}; if(!isset($chr[$char])) { // invalid character return false; } - for($j=0; $j < 9; $j++) { + for ($j = 0; $j < 9; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { @@ -290,8 +356,9 @@ class TCPDFBarcode { 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 = ''; - for ($i = 0 ; $i < strlen($code); $i++) { + $code_ext = ''; + $clen = strlen($code); + for ($i = 0 ; $i < $clen; ++$i) { if (ord($code{$i}) > 127) { return false; } @@ -312,8 +379,9 @@ class TCPDFBarcode { '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; - for ($i=0 ; $i < strlen($code); $i++) { + $sum = 0; + $clen = strlen($code); + for ($i = 0 ; $i < $clen; ++$i) { $k = array_keys($chars, $code{$i}); $sum += $k[0]; } @@ -322,14 +390,343 @@ class TCPDFBarcode { } /** - * Interleaved 2 of 5 barcodes. + * CODE 93 - USS-93 + * Compact code similar to Code 39 + * @param string $code code to represent. + * @param boolean $checksum if true add a checksum to the code + * @return array barcode representation. + * @access protected + */ + protected function barcode_code93($code) { + $chr['0'] = '131112'; + $chr['1'] = '111213'; + $chr['2'] = '111312'; + $chr['3'] = '111411'; + $chr['4'] = '121113'; + $chr['5'] = '121212'; + $chr['6'] = '121311'; + $chr['7'] = '111114'; + $chr['8'] = '131211'; + $chr['9'] = '141111'; + $chr['A'] = '211113'; + $chr['B'] = '211212'; + $chr['C'] = '211311'; + $chr['D'] = '221112'; + $chr['E'] = '221211'; + $chr['F'] = '231111'; + $chr['G'] = '112113'; + $chr['H'] = '112212'; + $chr['I'] = '112311'; + $chr['J'] = '122112'; + $chr['K'] = '132111'; + $chr['L'] = '111123'; + $chr['M'] = '111222'; + $chr['N'] = '111321'; + $chr['O'] = '121122'; + $chr['P'] = '131121'; + $chr['Q'] = '212112'; + $chr['R'] = '212211'; + $chr['S'] = '211122'; + $chr['T'] = '211221'; + $chr['U'] = '221121'; + $chr['V'] = '222111'; + $chr['W'] = '112122'; + $chr['X'] = '112221'; + $chr['Y'] = '122121'; + $chr['Z'] = '123111'; + $chr['-'] = '121131'; + $chr['.'] = '311112'; + $chr[' '] = '311211'; + $chr['$'] = '321111'; + $chr['/'] = '112131'; + $chr['+'] = '113121'; + $chr['%'] = '211131'; + $chr[128] = '121221'; // ($) + $chr[129] = '311121'; // (/) + $chr[130] = '122211'; // (+) + $chr[131] = '312111'; // (%) + $chr['*'] = '111141'; + $code = strtoupper($code); + $encode = array( + 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) { + return false; + } + $code_ext .= $encode[$code{$i}]; + } + // checksum + $code .= $this->checksum_code93($code); + // add start and stop codes + $code = '*'.$code.'*'; + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $k = 0; + $clen = strlen($code); + for ($i = 0; $i < $clen; ++$i) { + $char = $code{$i}; + if(!isset($chr[$char])) { + // invalid character + return false; + } + for ($j = 0; $j < 6; ++$j) { + if (($j % 2) == 0) { + $t = true; // bar + } else { + $t = false; // space + } + $w = $chr[$char]{$j}; + $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); + $bararray['maxw'] += $w; + ++$k; + } + } + $bararray['bcode'][$k] = array('t' => true, 'w' => 1, 'h' => 1, 'p' => 0); + $bararray['maxw'] += 1; + ++$k; + return $bararray; + } + + /** + * Calculate CODE 93 checksum (modulo 47). + * @param string $code code to represent. + * @return string checksum code. + * @access protected + */ + protected function checksum_code93($code) { + $chars = array( + '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(129).chr(130).chr(131), '$/+%'); + $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]; + return $c.$k; + } + + /** + * Checksum for standard 2 of 5 barcodes. + * @param string $code code to process. + * @return int checksum. + * @access protected + */ + protected function checksum_s25($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; + } + + /** + * MSI. + * Variation of Plessey code, with similar applications + * Contains digits (0 to 9) and encodes the data only in the width of bars. + * @param string $code code to represent. + * @param boolean $checksum if true add a checksum to the code (modulo 11) + * @return array barcode representation. + * @access protected + */ + protected function barcode_msi($code, $checksum=false) { + $chr['0'] = '100100100100'; + $chr['1'] = '100100100110'; + $chr['2'] = '100100110100'; + $chr['3'] = '100100110110'; + $chr['4'] = '100110100100'; + $chr['5'] = '100110100110'; + $chr['6'] = '100110110100'; + $chr['7'] = '100110110110'; + $chr['8'] = '110100100100'; + $chr['9'] = '110100100110'; + $chr['A'] = '110100110100'; + $chr['B'] = '110100110110'; + $chr['C'] = '110110100100'; + $chr['D'] = '110110100110'; + $chr['E'] = '110110110100'; + $chr['F'] = '110110110110'; + 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; + } + $seq = '110'; // left guard + $clen = strlen($code); + for ($i = 0; $i < $clen; ++$i) { + $digit = $code{$i}; + if (!isset($chr[$digit])) { + // invalid character + return false; + } + $seq .= $chr[$digit]; + } + $seq .= '1001'; // right guard + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + return $this->binseq_to_array($seq, $bararray); + } + + /** + * 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. + * @param string $code code to represent. + * @param boolean $checksum if true add a checksum to the code + * @return array barcode representation. + * @access protected + */ + protected function barcode_s25($code, $checksum=false) { + $chr['0'] = '10101110111010'; + $chr['1'] = '11101010101110'; + $chr['2'] = '10111010101110'; + $chr['3'] = '11101110101010'; + $chr['4'] = '10101110101110'; + $chr['5'] = '11101011101010'; + $chr['6'] = '10111011101010'; + $chr['7'] = '10101011101110'; + $chr['8'] = '10101110111010'; + $chr['9'] = '10111010111010'; + if ($checksum) { + // add checksum + $code .= $this->checksum_s25($code); + } + 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 + return false; + } + $seq .= $chr[$digit]; + } + $seq .= '1101011'; + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + return $this->binseq_to_array($seq, $bararray); + } + + /** + * Convert binary barcode sequence to TCPDF barcode array + * @param string $seq barcode as binary sequence + * òparam array $bararray TCPDF barcode array to fill up + * @return array barcode representation. + * @access protected + */ + protected function binseq_to_array($seq, $bararray) { + $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 + } + $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); + $bararray['maxw'] += $w; + ++$k; + $w = 0; + } + } + return $bararray; + } + + /** + * 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. * @param string $code code to represent. * @param boolean $checksum if true add a checksum to the code * @return array barcode representation. * @access protected */ - protected function barcode_i25($code) { + protected function barcode_i25($code, $checksum=false) { $chr['0'] = '11221'; $chr['1'] = '21112'; $chr['2'] = '12112'; @@ -341,8 +738,11 @@ class TCPDFBarcode { $chr['8'] = '21121'; $chr['9'] = '12121'; $chr['A'] = '11'; - $chr['Z'] = '21'; - + $chr['Z'] = '21'; + if ($checksum) { + // add checksum + $code .= $this->checksum_s25($code); + } if((strlen($code) % 2) != 0) { // add leading zero if code-length is odd $code = '0'.$code; @@ -351,8 +751,9 @@ class TCPDFBarcode { $code = 'AA'.strtolower($code).'ZA'; $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); - $k = 0; - for($i=0; $i < strlen($code); $i=$i+2) { + $k = 0; + $clen = strlen($code); + for ($i = 0; $i < $clen; $i = ($i + 2)) { $char_bar = $code{$i}; $char_space = $code{$i+1}; if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) { @@ -360,11 +761,13 @@ class TCPDFBarcode { return false; } // create a bar-space sequence - $seq = ''; - for($s=0; $s < strlen($chr[$char_bar]); $s++){ + $seq = ''; + $chrlen = strlen($chr[$char_bar]); + for ($s = 0; $s < $chrlen; $s++){ $seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s}; - } - for($j=0; $j < strlen($seq); $j++) { + } + $seqlen = strlen($seq); + for ($j = 0; $j < $seqlen; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { @@ -381,7 +784,7 @@ class TCPDFBarcode { /** * C128 barcodes. - * + * Very capable code, excellent density, high reliability; in very wide use world-wide * @param string $code code to represent. * @param string $type barcode type: A, B or C * @return array barcode representation. @@ -495,15 +898,15 @@ class TCPDFBarcode { '211412', /* 103 START A */ '211214', /* 104 START B */ '211232', /* 105 START C */ - '233111', /* STOP */ - '200000' /* END */ + '233111', /* STOP */ + '200000' /* END */ ); $keys = ''; switch(strtoupper($type)) { case 'A': { $startid = 103; $keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'; - for($i = 0; $i < 32; $i++) { + for ($i = 0; $i < 32; ++$i) { $keys .= chr($i); } break; @@ -517,14 +920,14 @@ class TCPDFBarcode { $startid = 105; $keys = ''; if ((strlen($code) % 2) != 0) { - //echo "The length of barcode value must be even ($code). You must pad the number with zeros.\n"; + // The length of barcode value must be even ($code). You must pad the number with zeros return false; } - for($i = 0; $i <= 99; $i++) { + for ($i = 0; $i <= 99; ++$i) { $keys .= chr($i); } $new_code = ''; - for ($i=0; $i < (strlen($code) / 2); $i++) { + for ($i = 0; $i < (strlen($code) / 2); ++$i) { $new_code .= chr(intval($code{(2 * $i)}.$code{(2 * $i + 1)})); } $code = $new_code; @@ -535,18 +938,18 @@ class TCPDFBarcode { } } // calculate check character - $sum = $startid; - for ($i=0; $i < strlen($code); $i++) { + $sum = $startid; + $clen = strlen($code); + for ($i = 0; $i < $clen; ++$i) { $sum += (strpos($keys, $code{$i}) * ($i+1)); } $check = ($sum % 103); - // add start, check and stop codes $code = chr($startid).$code.chr($check).chr(106).chr(107); $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); $k = 0; $len = strlen($code); - for($i=0; $i < $len; $i++) { + for ($i = 0; $i < $len; ++$i) { $ck = strpos($keys, $code{$i}); if (($i == 0) OR ($i > ($len-4))) { $char_num = ord($code{$i}); @@ -557,7 +960,7 @@ class TCPDFBarcode { // invalid character return false; } - for($j=0; $j < 6; $j++) { + for ($j = 0; $j < 6; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { @@ -573,47 +976,82 @@ class TCPDFBarcode { } /** - * EAN13 and UPC-A barcodes. + * 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 * @param string $code code to represent. - * @param string $len barcode type: 13 = EAN13, 12 = UPC-A + * @param string $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A * @return array barcode representation. * @access protected */ - protected function barcode_ean13($code, $len=13) { + protected function barcode_eanupc($code, $len=13) { + $upce = false; + if ($len == 6) { + $len = 12; // UPC-A + $upce = true; // UPC-E mode + } + $data_len = $len - 1; //Padding - $code = str_pad($code, $len-1, '0', STR_PAD_LEFT); - if($len == 12) { - $code = '0'.$code; + $code = str_pad($code, $data_len, '0', STR_PAD_LEFT); + $code_len = strlen($code); + // calculate check digit + $sum_a = 0; + for ($i = 1; $i < $data_len; $i+=2) { + $sum_a += $code{$i}; + } + if ($len > 12) { + $sum_a *= 3; + } + $sum_b = 0; + for ($i = 0; $i < $data_len; $i+=2) { + $sum_b += ($code{$i}); + } + if ($len < 13) { + $sum_b *= 3; } - // add check digit - if(strlen($code) == 12) { - $sum=0; - for($i=1;$i<=11;$i+=2) { - $sum += (3 * $code{$i}); - } - for($i=0; $i <= 10; $i+=2) { - $sum += ($code{$i}); - } - $r = $sum % 10; - if($r > 0) { - $r = (10 - $r); - } + $r = ($sum_a + $sum_b) % 10; + if($r > 0) { + $r = (10 - $r); + } + if ($code_len == $data_len) { + // add check digit $code .= $r; - } else { // test checkdigit - $sum = 0; - for($i=1; $i <= 11; $i+=2) { - $sum += (3 * $code{$i}); - } - for($i=0; $i <= 10; $i+=2) { - $sum += $code{$i}; - } - if ((($sum + $code{12}) % 10) != 0) { - return false; - } + } elseif ($r !== intval($code{$data_len})) { + // wrong checkdigit + return false; + } + if ($len == 12) { + // UPC-A + $code = '0'.$code; + ++$len; + } + if ($upce) { + // convert UPC-A to UPC-E + $tmp = substr($code, 4, 3); + if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) { + // manufacturer code ends in 000, 100, or 200 + $upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1); + } else { + $tmp = substr($code, 5, 2); + if ($tmp == '00') { + // manufacturer code ends in 00 + $upce_code = substr($code, 2, 3).substr($code, 10, 2).'3'; + } else { + $tmp = substr($code, 6, 1); + if ($tmp == '0') { + // manufacturer code ends in 0 + $upce_code = substr($code, 2, 4).substr($code, 11, 1).'4'; + } else { + // manufacturer code does not end in zero + $upce_code = substr($code, 2, 5).substr($code, 11, 1); + } + } + } } //Convert digits to bars $codes = array( - 'A'=>array( + 'A'=>array( // left odd parity '0'=>'0001101', '1'=>'0011001', '2'=>'0010011', @@ -624,7 +1062,7 @@ class TCPDFBarcode { '7'=>'0111011', '8'=>'0110111', '9'=>'0001011'), - 'B'=>array( + 'B'=>array( // left even parity '0'=>'0100111', '1'=>'0110011', '2'=>'0011011', @@ -635,7 +1073,7 @@ class TCPDFBarcode { '7'=>'0010001', '8'=>'0001001', '9'=>'0010111'), - 'C'=>array( + 'C'=>array( // right '0'=>'1110010', '1'=>'1100110', '2'=>'1101100', @@ -658,25 +1096,65 @@ class TCPDFBarcode { '7'=>array('A','B','A','B','A','B'), '8'=>array('A','B','A','B','B','A'), '9'=>array('A','B','B','A','B','A') + ); + $upce_parities = array(); + $upce_parities[0] = array( + '0'=>array('B','B','B','A','A','A'), + '1'=>array('B','B','A','B','A','A'), + '2'=>array('B','B','A','A','B','A'), + '3'=>array('B','B','A','A','A','B'), + '4'=>array('B','A','B','B','A','A'), + '5'=>array('B','A','A','B','B','A'), + '6'=>array('B','A','A','A','B','B'), + '7'=>array('B','A','B','A','B','A'), + '8'=>array('B','A','B','A','A','B'), + '9'=>array('B','A','A','B','A','B') + ); + $upce_parities[1] = array( + '0'=>array('A','A','A','B','B','B'), + '1'=>array('A','A','B','A','B','B'), + '2'=>array('A','A','B','B','A','B'), + '3'=>array('A','A','B','B','B','A'), + '4'=>array('A','B','A','A','B','B'), + '5'=>array('A','B','B','A','A','B'), + '6'=>array('A','B','B','B','A','A'), + '7'=>array('A','B','A','B','A','B'), + '8'=>array('A','B','A','B','B','A'), + '9'=>array('A','B','B','A','B','A') ); - - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); $k = 0; - $seq = '101'; - $p = $parities[$code{0}]; - for($i=1; $i < 7; $i++) { - $seq .= $codes[$p[$i-1]][$code{$i}]; + $seq = '101'; // left guard bar + if ($upce) { + $bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $p = $upce_parities[$code{1}][$r]; + for ($i = 0; $i < 6; ++$i) { + $seq .= $codes[$p[$i]][$upce_code{$i}]; + } + $seq .= '010101'; // right guard bar + } else { + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $half_len = ceil($len / 2); + if ($len == 8) { + for ($i = 0; $i < $half_len; ++$i) { + $seq .= $codes['A'][$code{$i}]; + } + } else { + $p = $parities[$code{0}]; + for ($i = 1; $i < $half_len; ++$i) { + $seq .= $codes[$p[$i-1]][$code{$i}]; + } + } + $seq .= '01010'; // center guard bar + for ($i = $half_len; $i < $len; ++$i) { + $seq .= $codes['C'][$code{$i}]; + } + $seq .= '101'; // right guard bar } - $seq .= '01010'; - for($i=7; $i < 13; $i++) { - $seq .= $codes['C'][$code{$i}]; - } - $seq .= '101'; - $len = strlen($seq); + $clen = strlen($seq); $w = 0; - for($i=0; $i < $len; $i++) { + for ($i = 0; $i < $clen; ++$i) { $w += 1; - if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) { + if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) { if ($seq{$i} == '1') { $t = true; // bar } else { @@ -692,25 +1170,118 @@ class TCPDFBarcode { } /** - * POSTNET barcodes. - * @param string $code zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD. + * 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 + * @param string $code code to represent. + * @param string $len barcode type: 2 = 2-Digit, 5 = 5-Digit * @return array barcode representation. * @access protected */ - protected function barcode_postnet($code) { - // bar lenght - $barlen = Array( - 0 => Array(2,2,1,1,1), - 1 => Array(1,1,1,2,2), - 2 => Array(1,1,2,1,2), - 3 => Array(1,1,2,2,1), - 4 => Array(1,2,1,1,2), - 5 => Array(1,2,1,2,1), - 6 => Array(1,2,2,1,1), - 7 => Array(2,1,1,1,2), - 8 => Array(2,1,1,2,1), - 9 => Array(2,1,2,1,1) - ); + protected function barcode_eanext($code, $len=5) { + //Padding + $code = str_pad($code, $len, '0', STR_PAD_LEFT); + // calculate check digit + if ($len == 2) { + $r = $code % 4; + } elseif ($len == 5) { + $r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3})); + $r %= 10; + } else { + return false; + } + //Convert digits to bars + $codes = array( + 'A'=>array( // left odd parity + '0'=>'0001101', + '1'=>'0011001', + '2'=>'0010011', + '3'=>'0111101', + '4'=>'0100011', + '5'=>'0110001', + '6'=>'0101111', + '7'=>'0111011', + '8'=>'0110111', + '9'=>'0001011'), + 'B'=>array( // left even parity + '0'=>'0100111', + '1'=>'0110011', + '2'=>'0011011', + '3'=>'0100001', + '4'=>'0011101', + '5'=>'0111001', + '6'=>'0000101', + '7'=>'0010001', + '8'=>'0001001', + '9'=>'0010111') + ); + $parities = array(); + $parities[2] = array( + '0'=>array('A','A'), + '1'=>array('A','B'), + '2'=>array('B','A'), + '3'=>array('B','B') + ); + $parities[5] = array( + '0'=>array('B','B','A','A','A'), + '1'=>array('B','A','B','A','A'), + '2'=>array('B','A','A','B','A'), + '3'=>array('B','A','A','A','B'), + '4'=>array('A','B','B','A','A'), + '5'=>array('A','A','B','B','A'), + '6'=>array('A','A','A','B','B'), + '7'=>array('A','B','A','B','A'), + '8'=>array('A','B','A','A','B'), + '9'=>array('A','A','B','A','B') + ); + $p = $parities[$len][$r]; + $seq = '1011'; // left guard bar + $seq .= $codes[$p[0]][$code{0}]; + for ($i = 1; $i < $len; ++$i) { + $seq .= '01'; // separator + $seq .= $codes[$p[$i]][$code{$i}]; + } + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + return $this->binseq_to_array($seq, $bararray); + } + + /** + * POSTNET and PLANET barcodes. + * Used by U.S. Postal Service for automated mail sorting + * @param string $code zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD. + * @param boolean $planet if true print the PLANET barcode, otherwise print POSTNET + * @return array barcode representation. + * @access protected + */ + protected function barcode_postnet($code, $planet=false) { + // bar lenght + if ($planet) { + $barlen = Array( + 0 => Array(1,1,2,2,2), + 1 => Array(2,2,2,1,1), + 2 => Array(2,2,1,2,1), + 3 => Array(2,2,1,1,2), + 4 => Array(2,1,2,2,1), + 5 => Array(2,1,2,1,2), + 6 => Array(2,1,1,2,2), + 7 => Array(1,2,2,2,1), + 8 => Array(1,2,2,1,2), + 9 => Array(1,2,1,2,2) + ); + } else { + $barlen = Array( + 0 => Array(2,2,1,1,1), + 1 => Array(1,1,1,2,2), + 2 => Array(1,1,2,1,2), + 3 => Array(1,1,2,2,1), + 4 => Array(1,2,1,1,2), + 5 => Array(1,2,1,2,1), + 6 => Array(1,2,2,1,1), + 7 => Array(2,1,1,1,2), + 8 => Array(2,1,1,2,1), + 9 => Array(2,1,2,1,1) + ); + } $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array()); $k = 0; $code = str_replace('-', '', $code); @@ -718,7 +1289,7 @@ class TCPDFBarcode { $len = strlen($code); // calculate checksum $sum = 0; - for($i=0; $i < $len; $i++) { + for ($i = 0; $i < $len; ++$i) { $sum += intval($code{$i}); } $chkd = ($sum % 10); @@ -731,8 +1302,8 @@ class TCPDFBarcode { $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0); $bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0); $bararray['maxw'] += 2; - for ($i=0; $i < $len; $i++) { - for ($j=0; $j < 5; $j++) { + for ($i = 0; $i < $len; ++$i) { + for ($j = 0; $j < 5; ++$j) { $h = $barlen[$code{$i}][$j]; $p = floor(1 / $h); $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p); @@ -747,7 +1318,161 @@ class TCPDFBarcode { } /** - * CODABAR barcodes. + * RMS4CC - CBC - KIX + * RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) + * RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service. + * @param string $code code to print + * @param boolean $kix if true prints the KIX variation (doesn't use the start and end symbols, and the checksum) - in this case the house number must be sufficed with an X and placed at the end of the code. + * @return array barcode representation. + * @access protected + */ + protected function barcode_rms4cc($code, $kix=false) { + $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 = array( + '0' => array(3,3,2,2), + '1' => array(3,4,1,2), + '2' => array(3,4,2,1), + '3' => array(4,3,1,2), + '4' => array(4,3,2,1), + '5' => array(4,4,1,1), + '6' => array(3,1,4,2), + '7' => array(3,2,3,2), + '8' => array(3,2,4,1), + '9' => array(4,1,3,2), + 'A' => array(4,1,4,1), + 'B' => array(4,2,3,1), + 'C' => array(3,1,2,4), + 'D' => array(3,2,1,4), + 'E' => array(3,2,2,3), + 'F' => array(4,1,1,4), + 'G' => array(4,1,2,3), + 'H' => array(4,2,1,3), + 'I' => array(1,3,4,2), + 'J' => array(1,4,3,2), + 'K' => array(1,4,4,1), + 'L' => array(2,3,3,2), + 'M' => array(2,3,4,1), + 'N' => array(2,4,3,1), + 'O' => array(1,3,2,4), + 'P' => array(1,4,1,4), + 'Q' => array(1,4,2,3), + 'R' => array(2,3,1,4), + 'S' => array(2,3,2,3), + 'T' => array(2,4,1,3), + 'U' => array(1,1,4,4), + 'V' => array(1,2,3,4), + 'W' => array(1,2,4,3), + 'X' => array(2,1,3,4), + 'Y' => array(2,1,4,3), + 'Z' => array(2,2,3,3) + ); + $code = strtoupper($code); + $len = strlen($code); + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array()); + if ($notkix) { + // table for checksum calculation (row,col) + $checktable = array( + '0' => array(1,1), + '1' => array(1,2), + '2' => array(1,3), + '3' => array(1,4), + '4' => array(1,5), + '5' => array(1,0), + '6' => array(2,1), + '7' => array(2,2), + '8' => array(2,3), + '9' => array(2,4), + 'A' => array(2,5), + 'B' => array(2,0), + 'C' => array(3,1), + 'D' => array(3,2), + 'E' => array(3,3), + 'F' => array(3,4), + 'G' => array(3,5), + 'H' => array(3,0), + 'I' => array(4,1), + 'J' => array(4,2), + 'K' => array(4,3), + 'L' => array(4,4), + 'M' => array(4,5), + 'N' => array(4,0), + 'O' => array(5,1), + 'P' => array(5,2), + 'Q' => array(5,3), + 'R' => array(5,4), + 'S' => array(5,5), + 'T' => array(5,0), + 'U' => array(0,1), + 'V' => array(0,2), + 'W' => array(0,3), + 'X' => array(0,4), + 'Y' => array(0,5), + 'Z' => array(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, array($row,$col)); + $code .= $chk[0]; + ++$len; + } + $k = 0; + if ($notkix) { + // start bar + $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0); + $bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0); + $bararray['maxw'] += 2; + } + for ($i = 0; $i < $len; ++$i) { + for ($j = 0; $j < 4; ++$j) { + switch ($barmode[$code{$i}][$j]) { + case 1: { + $p = 0; + $h = 2; + break; + } + case 2: { + $p = 0; + $h = 3; + break; + } + case 3: { + $p = 1; + $h = 1; + break; + } + case 4: { + $p = 1; + $h = 2; + break; + } + } + $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p); + $bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0); + $bararray['maxw'] += 2; + } + } + if ($notkix) { + // stop bar + $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 3, 'p' => 0); + $bararray['maxw'] += 1; + } + return $bararray; + } + + /** + * CODABAR barcodes. + * Older code often used in library systems, sometimes in blood banks * @param string $code code to represent. * @return array barcode representation. * @access protected @@ -775,19 +1500,18 @@ class TCPDFBarcode { 'C' => '11121221', 'D' => '11122211' ); - $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); $k = 0; $w = 0; $seq = ''; $code = 'A'.strtoupper($code).'A'; $len = strlen($code); - for($i=0; $i < $len; $i++) { + for ($i = 0; $i < $len; ++$i) { if (!isset($chr[$code{$i}])) { return false; } $seq = $chr[$code{$i}]; - for($j=0; $j < 8; $j++) { + for ($j = 0; $j < 8; ++$j) { if (($j % 2) == 0) { $t = true; // bar } else { @@ -802,6 +1526,183 @@ class TCPDFBarcode { return $bararray; } + /** + * CODE11 barcodes. + * Used primarily for labeling telecommunications equipment + * @param string $code code to represent. + * @return array barcode representation. + * @access protected + */ + protected function barcode_code11($code) { + $chr = array( + '0' => '111121', + '1' => '211121', + '2' => '121121', + '3' => '221111', + '4' => '112121', + '5' => '212111', + '6' => '122111', + '7' => '111221', + '8' => '211211', + '9' => '211111', + '-' => '112111', + 'S' => '112211' + ); + + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $k = 0; + $w = 0; + $seq = ''; + $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 = intval($digit); + } + $check += ($dval * $p); + ++$p; + if ($p > 10) { + $p = 1; + } + } + $check %= 11; + if ($check == 10) { + $check = '-'; + } + $code .= $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 = intval($digit); + } + $check += ($dval * $p); + ++$p; + if ($p > 9) { + $p = 1; + } + } + $check %= 11; + $code .= $check; + ++$len; + } + $code = 'S'.$code.'S'; + $len += 3; + for ($i = 0; $i < $len; ++$i) { + if (!isset($chr[$code{$i}])) { + return false; + } + $seq = $chr[$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] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); + $bararray['maxw'] += $w; + ++$k; + } + } + return $bararray; + } + + /** + * Pharmacode + * Contains digits (0 to 9) + * @param string $code code to represent. + * @return array barcode representation. + * @access protected + */ + protected function barcode_pharmacode($code) { + $seq = ''; + $code = intval($code); + while ($code > 0) { + if (($code % 2) == 0) { + $seq .= '11100'; + $code -= 2; + } else { + $seq .= '100'; + $code -= 1; + } + $code /= 2; + } + $seq = substr($seq, 0, -2); + $seq = strrev($seq); + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + return $this->binseq_to_array($seq, $bararray); + } + + /** + * Pharmacode two-track + * Contains digits (0 to 9) + * @param string $code code to represent. + * @return array barcode representation. + * @access protected + */ + protected function barcode_pharmacode2t($code) { + $seq = ''; + $code = intval($code); + do { + switch ($code % 3) { + case 0: { + $seq .= '3'; + $code = ($code - 3) / 3; + break; + } + case 1: { + $seq .= '1'; + $code = ($code - 1) / 3; + break; + } + case 2: { + $seq .= '2'; + $code = ($code - 2) / 3; + break; + } + } + } while($code != 0); + $seq = strrev($seq); + $k = 0; + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array()); + $len = strlen($seq); + for ($i = 0; $i < $len; ++$i) { + switch ($seq{$i}) { + case '1': { + $p = 1; + $h = 1; + break; + } + case '2': { + $p = 0; + $h = 1; + break; + } + case '3': { + $p = 0; + $h = 2; + break; + } + } + $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p); + $bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0); + $bararray['maxw'] += 2; + } + unset($bararray['bcode'][($k - 1)]); + --$bararray['maxw']; + return $bararray; + } } // end of class //============================================================+ diff --git a/doc/classtrees_com-tecnick-tcpdf.html b/doc/classtrees_com-tecnick-tcpdf.html index 2c5430e..caefb5e 100644 --- a/doc/classtrees_com-tecnick-tcpdf.html +++ b/doc/classtrees_com-tecnick-tcpdf.html @@ -45,7 +45,7 @@

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/com-tecnick-tcpdf/TCPDF.html b/doc/com-tecnick-tcpdf/TCPDF.html index a057eaa..08bf957 100644 --- a/doc/com-tecnick-tcpdf/TCPDF.html +++ b/doc/com-tecnick-tcpdf/TCPDF.html @@ -74,7 +74,7 @@ Source Location: /tcpdf.php

    Version:

    @@ -580,7 +580,7 @@ This is a PHP class for generating PDF documents without requiring external exte author:  Nicola Asuni - info@tecnick.com - version:  4.5.038 + version:  4.5.039 link:  http://www.tcpdf.org @@ -16325,7 +16325,7 @@ $align = ''])
    - Print 1D Barcode.



    + Print a Linear Barcode.



    Tags:

    @@ -18859,7 +18859,7 @@ $file)

    - Documentation generated on Fri, 10 Apr 2009 14:17:42 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:28 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/com-tecnick-tcpdf/TCPDFBarcode.html b/doc/com-tecnick-tcpdf/TCPDFBarcode.html index 3ef30f4..a4a836f 100644 --- a/doc/com-tecnick-tcpdf/TCPDFBarcode.html +++ b/doc/com-tecnick-tcpdf/TCPDFBarcode.html @@ -74,7 +74,7 @@ Source Location: /barcodes.php

    Version:

    @@ -94,11 +94,22 @@ Source Location: /barcodes.php

  • __construct
  • barcode_c128
  • barcode_codabar
  • +
  • barcode_code11
  • barcode_code39
  • -
  • barcode_ean13
  • +
  • barcode_code93
  • +
  • barcode_eanext
  • +
  • barcode_eanupc
  • barcode_i25
  • +
  • barcode_msi
  • +
  • barcode_pharmacode
  • +
  • barcode_pharmacode2t
  • barcode_postnet
  • +
  • barcode_rms4cc
  • +
  • barcode_s25
  • +
  • binseq_to_array
  • checksum_code39
  • +
  • checksum_code93
  • +
  • checksum_s25
  • encode_code39_ext
  • getBarcodeArray
  • setBarcode
  • @@ -130,7 +141,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit author:  Nicola Asuni - version:  1.0.005 + version:  1.0.006 link:  http://www.tcpdf.org @@ -220,7 +231,7 @@ $type) string   $type   - type of barcode: + type of barcode:

    @@ -228,7 +239,7 @@ $type)
    -

    method barcode_c128 [line 390]

    +

    method barcode_c128 [line 793]

    @@ -239,7 +250,7 @@ $type = 'B'])

    - C128 barcodes.



    + C128 barcodes.

    Very capable code, excellent density, high reliability; in very wide use world-wide




    Tags:

    @@ -273,7 +284,7 @@ $type = 'B'])
    -

    method barcode_codabar [line 755]

    +

    method barcode_codabar [line 1480]

    @@ -283,7 +294,46 @@ $code)

    - CODABAR barcodes.



    + CODABAR barcodes.

    Older code often used in library systems, sometimes in blood banks




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + +
    string  $code  code to represent.
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_code11 [line 1536]

    +
    +
    +
    + array barcode_code11( +string +$code) +
    +

    + + CODE11 barcodes.

    Used primarily for labeling telecommunications equipment




    Tags:

    @@ -312,7 +362,7 @@ $code)
    -

    method barcode_code39 [line 166]

    +

    method barcode_code39 [line 231]

    @@ -324,7 +374,7 @@ $checksum = false])

    - CODE 39



    + CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.

    General-purpose code in very wide use world-wide




    Tags:

    @@ -362,64 +412,19 @@ $checksum = false])
    [ Top ]

    - -

    method barcode_ean13 [line 582]

    + +

    method barcode_code93 [line 400]

    - array barcode_ean13( -string -$code, [string -$len = 13]) -
    -

    - - EAN13 and UPC-A barcodes.



    -

    Tags:

    -
    - - - - - - - -
    return:  barcode representation.
    access:  protected
    -
    -

    - - -

    Parameters:

    -
    - - - - - - - - - - - -
    string  $code  code to represent.
    string  $len  barcode type: 13 = EAN13, 12 = UPC-A
    -

    -
    [ Top ]
    -
    -
    - -

    method barcode_i25 [line 332]

    -
    -
    -
    - array barcode_i25( + array barcode_code93( string $code, boolean $checksum)

    - Interleaved 2 of 5 barcodes.

    Contains digits (0 to 9) and encodes the data in the width of both bars and spaces.




    + CODE 93 - USS-93

    Compact code similar to Code 39




    Tags:

    @@ -452,18 +457,277 @@ $checksum)
    [ Top ]

    - -

    method barcode_postnet [line 700]

    + +

    method barcode_eanext [line 1181]

    - array barcode_postnet( + array barcode_eanext( +string +$code, [string +$len = 5]) +
    +

    + + 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




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + + + +
    string  $code  code to represent.
    string  $len  barcode type: 2 = 2-Digit, 5 = 5-Digit
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_eanupc [line 988]

    +
    +
    +
    + array barcode_eanupc( +string +$code, [string +$len = 13]) +
    +

    + + 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




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + + + +
    string  $code  code to represent.
    string  $len  barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_i25 [line 729]

    +
    +
    +
    + array barcode_i25( +string +$code, [boolean +$checksum = false]) +
    +

    + + 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.




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + + + +
    string  $code  code to represent.
    boolean  $checksum  if true add a checksum to the code
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_msi [line 599]

    +
    +
    +
    + array barcode_msi( +string +$code, [boolean +$checksum = false]) +
    +

    + + MSI.

    Variation of Plessey code, with similar applications Contains digits (0 to 9) and encodes the data only in the width of bars.




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + + + +
    string  $code  code to represent.
    boolean  $checksum  if true add a checksum to the code (modulo 11)
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_pharmacode [line 1628]

    +
    +
    +
    + array barcode_pharmacode( string $code)

    - POSTNET barcodes.



    + Pharmacode

    Contains digits (0 to 9)




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + +
    string  $code  code to represent.
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_pharmacode2t [line 1654]

    +
    +
    +
    + array barcode_pharmacode2t( +string +$code) +
    +

    + + Pharmacode two-track

    Contains digits (0 to 9)




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + +
    string  $code  code to represent.
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_postnet [line 1256]

    +
    +
    +
    + array barcode_postnet( +string +$code, [boolean +$planet = false]) +
    +

    + + POSTNET and PLANET barcodes.

    Used by U.S. Postal Service for automated mail sorting




    Tags:

    @@ -485,6 +749,146 @@ $code) + + + + + + +
    string   $code   zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD.
    boolean  $planet  if true print the PLANET barcode, otherwise print POSTNET
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_rms4cc [line 1329]

    +
    +
    +
    + array barcode_rms4cc( +string +$code, [boolean +$kix = false]) +
    +

    + + RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.



    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + + + +
    string  $code  code to print
    boolean  $kix  if true prints the KIX variation (doesn't use the start and end symbols, and the checksum) - in this case the house number must be sufficed with an X and placed at the end of the code.
    +

    +
    [ Top ]
    +
    +
    + +

    method barcode_s25 [line 658]

    +
    +
    +
    + array barcode_s25( +string +$code, [boolean +$checksum = false]) +
    +

    + + 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.




    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + + + +
    string  $code  code to represent.
    boolean  $checksum  if true add a checksum to the code
    +

    +
    [ Top ]
    +
    +
    + +

    method binseq_to_array [line 699]

    +
    +
    +
    + array binseq_to_array( +string +$seq, +$bararray) +
    +

    + + Convert binary barcode sequence to TCPDF barcode array



    +

    Tags:

    +
    + + + + + + + +
    return:  barcode representation.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + + + + +
    string  $seq  barcode as binary sequence òparam array $bararray TCPDF barcode array to fill up
      $bararray  

    @@ -492,7 +896,7 @@ $code)

    -

    method checksum_code39 [line 309]

    +

    method checksum_code39 [line 376]

    diff --git a/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html b/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html index 2bb223a..587d0b6 100644 --- a/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html +++ b/doc/com-tecnick-tcpdf/_config---tcpdf_config.php.html @@ -507,7 +507,7 @@ Configuration file for TCPDF.




    - Documentation generated on Fri, 10 Apr 2009 14:17:47 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:33 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/com-tecnick-tcpdf/_barcodes.php.html b/doc/com-tecnick-tcpdf/_barcodes.php.html index cc334df..0680ec6 100644 --- a/doc/com-tecnick-tcpdf/_barcodes.php.html +++ b/doc/com-tecnick-tcpdf/_barcodes.php.html @@ -73,7 +73,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit - + @@ -96,7 +96,7 @@ PHP class to creates array representations for common 1D barcodes to be used wit

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    @@ -529,9 +933,87 @@ $code)
    [ Top ]
    +
    + +

    method checksum_code93 [line 528]

    +
    +
    +
    + string checksum_code93( +string +$code) +
    +

    + + Calculate CODE 93 checksum (modulo 47).



    +

    Tags:

    +
    + + + + + + + +
    return:  checksum code.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + +
    string  $code  code to represent.
    +

    +
    [ Top ]
    +
    +
    + +

    method checksum_s25 [line 573]

    +
    +
    +
    + int checksum_s25( +string +$code) +
    +

    + + Checksum for standard 2 of 5 barcodes.



    +

    Tags:

    +
    + + + + + + + +
    return:  checksum.
    access:  protected
    +
    +

    + + +

    Parameters:

    +
    + + + + + + +
    string  $code  code to process.
    +

    +
    [ Top ]
    +

    -

    method encode_code39_ext [line 259]

    +

    method encode_code39_ext [line 325]

    - +
    @@ -629,7 +1111,7 @@ $type)
    string   $type  type of barcode:
    • C39 : CODE 39
    • C39+ : CODE 39 with checksum
    • C39E : CODE 39 EXTENDED
    • C39E+ : CODE 39 EXTENDED with checksum
    • I25 : Interleaved 2 of 5
    • C128A : CODE 128 A
    • C128B : CODE 128 B
    • C128C : CODE 128 C
    • EAN13 : EAN 13
    • UPCA : UPC-A
    • POSTNET : POSTNET
    • CODABAR : CODABAR
    type of barcode:
    • C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
    • C39+ : CODE 39 with checksum
    • C39E : CODE 39 EXTENDED
    • C39E+ : CODE 39 EXTENDED + CHECKSUM
    • C93 : CODE 93 - USS-93
    • S25 : Standard 2 of 5
    • S25+ : Standard 2 of 5 + CHECKSUM
    • I25 : Interleaved 2 of 5
    • I25+ : Interleaved 2 of 5 + CHECKSUM
    • C128A : CODE 128 A
    • C128B : CODE 128 B
    • C128C : CODE 128 C
    • EAN2 : 2-Digits UPC-Based Extention
    • EAN5 : 5-Digits UPC-Based Extention
    • EAN8 : EAN 8
    • EAN13 : EAN 13
    • UPCA : UPC-A
    • UPCE : UPC-E
    • MSI : MSI (Variation of Plessey code)
    • MSI+ : MSI + CHECKSUM (modulo 11)
    • POSTNET : POSTNET
    • PLANET : PLANET
    • RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
    • KIX : KIX (Klant index - Customer index)
    • CODABAR : CODABAR
    • CODE11 : CODE 11
    • PHARMA : PHARMACODE
    • PHARMA2T : PHARMACODE TWO-TRACKS

    @@ -640,7 +1122,7 @@ $type)

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    author:  Nicola Asuni
    version:  1.0.005version:  1.0.006
    copyright:  2008-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
    diff --git a/doc/com-tecnick-tcpdf/_htmlcolors.php.html b/doc/com-tecnick-tcpdf/_htmlcolors.php.html index 2534445..f301418 100644 --- a/doc/com-tecnick-tcpdf/_htmlcolors.php.html +++ b/doc/com-tecnick-tcpdf/_htmlcolors.php.html @@ -88,7 +88,7 @@ Array of WEB safe colors.




    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:28 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/com-tecnick-tcpdf/_tcpdf.php.html b/doc/com-tecnick-tcpdf/_tcpdf.php.html index 328bc32..d1b49d2 100644 --- a/doc/com-tecnick-tcpdf/_tcpdf.php.html +++ b/doc/com-tecnick-tcpdf/_tcpdf.php.html @@ -73,7 +73,7 @@ This is a PHP class for generating PDF documents without requiring external exte author:  Nicola Asuni - version:  4.5.038 + version:  4.5.039 copyright:  2002-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com @@ -104,7 +104,7 @@ unicode data

    - PDF_PRODUCER = 'TCPDF 4.5.038 (http://www.tcpdf.org)' + PDF_PRODUCER = 'TCPDF 4.5.039 (http://www.tcpdf.org)'
    @@ -115,7 +115,7 @@ unicode data


    - Documentation generated on Fri, 10 Apr 2009 14:17:42 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:28 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/com-tecnick-tcpdf/_unicode_data.php.html b/doc/com-tecnick-tcpdf/_unicode_data.php.html index b718f4e..156e291 100644 --- a/doc/com-tecnick-tcpdf/_unicode_data.php.html +++ b/doc/com-tecnick-tcpdf/_unicode_data.php.html @@ -237,7 +237,7 @@ Unicode Include file for TCPDF.




    - Documentation generated on Fri, 10 Apr 2009 14:17:47 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:33 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/elementindex.html b/doc/elementindex.html index b18c0a5..0660320 100644 --- a/doc/elementindex.html +++ b/doc/elementindex.html @@ -125,14 +125,32 @@
    in file barcodes.php, method TCPDFBarcode::barcode_c128()
        C128 barcodes.
    barcode_codabar
    in file barcodes.php, method TCPDFBarcode::barcode_codabar()
        CODABAR barcodes.
    +
    barcode_code11
    +
    in file barcodes.php, method TCPDFBarcode::barcode_code11()
        CODE11 barcodes.
    barcode_code39
    -
    in file barcodes.php, method TCPDFBarcode::barcode_code39()
        CODE 39
    -
    barcode_ean13
    -
    in file barcodes.php, method TCPDFBarcode::barcode_ean13()
        EAN13 and UPC-A barcodes.
    +
    in file barcodes.php, method TCPDFBarcode::barcode_code39()
        CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
    +
    barcode_code93
    +
    in file barcodes.php, method TCPDFBarcode::barcode_code93()
        CODE 93 - USS-93
    +
    barcode_eanext
    +
    in file barcodes.php, method TCPDFBarcode::barcode_eanext()
        UPC-Based Extentions
    +
    barcode_eanupc
    +
    in file barcodes.php, method TCPDFBarcode::barcode_eanupc()
        EAN13 and UPC-A barcodes.
    barcode_i25
    in file barcodes.php, method TCPDFBarcode::barcode_i25()
        Interleaved 2 of 5 barcodes.
    +
    barcode_msi
    +
    in file barcodes.php, method TCPDFBarcode::barcode_msi()
        MSI.
    +
    barcode_pharmacode
    +
    in file barcodes.php, method TCPDFBarcode::barcode_pharmacode()
        Pharmacode
    +
    barcode_pharmacode2t
    +
    in file barcodes.php, method TCPDFBarcode::barcode_pharmacode2t()
        Pharmacode two-track
    barcode_postnet
    -
    in file barcodes.php, method TCPDFBarcode::barcode_postnet()
        POSTNET barcodes.
    +
    in file barcodes.php, method TCPDFBarcode::barcode_postnet()
        POSTNET and PLANET barcodes.
    +
    barcode_rms4cc
    +
    in file barcodes.php, method TCPDFBarcode::barcode_rms4cc()
        RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.
    +
    barcode_s25
    +
    in file barcodes.php, method TCPDFBarcode::barcode_s25()
        Standard 2 of 5 barcodes.
    +
    binseq_to_array
    +
    in file barcodes.php, method TCPDFBarcode::binseq_to_array()
        Convert binary barcode sequence to TCPDF barcode array
    Bookmark
    in file tcpdf.php, method TCPDF::Bookmark()
    Button
    @@ -181,6 +199,10 @@
    in file tcpdf.php, method TCPDF::checkPageBreak()
        Add page if needed.
    checksum_code39
    in file barcodes.php, method TCPDFBarcode::checksum_code39()
        Calculate CODE 39 checksum (modulo 43).
    +
    checksum_code93
    +
    in file barcodes.php, method TCPDFBarcode::checksum_code93()
        Calculate CODE 93 checksum (modulo 47).
    +
    checksum_s25
    +
    in file barcodes.php, method TCPDFBarcode::checksum_s25()
        Checksum for standard 2 of 5 barcodes.
    Circle
    in file tcpdf.php, method TCPDF::Circle()
        Draws a circle.
    Clip
    @@ -1142,7 +1164,7 @@
    Write
    in file tcpdf.php, method TCPDF::Write()
        This method prints text from the current position.
    write1DBarcode
    -
    in file tcpdf.php, method TCPDF::write1DBarcode()
        Print 1D Barcode.
    +
    in file tcpdf.php, method TCPDF::write1DBarcode()
        Print a Linear Barcode.
    write2DBarcode
    in file tcpdf.php, method TCPDF::write2DBarcode()
        Print 2D Barcode.
    writeBarcode
    @@ -1314,7 +1336,7 @@ top

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/elementindex_com-tecnick-tcpdf.html b/doc/elementindex_com-tecnick-tcpdf.html index c2f1ed0..7d1c835 100644 --- a/doc/elementindex_com-tecnick-tcpdf.html +++ b/doc/elementindex_com-tecnick-tcpdf.html @@ -274,14 +274,32 @@
    in file barcodes.php, method TCPDFBarcode::barcode_c128()
        C128 barcodes.
    barcode_codabar
    in file barcodes.php, method TCPDFBarcode::barcode_codabar()
        CODABAR barcodes.
    +
    barcode_code11
    +
    in file barcodes.php, method TCPDFBarcode::barcode_code11()
        CODE11 barcodes.
    barcode_code39
    -
    in file barcodes.php, method TCPDFBarcode::barcode_code39()
        CODE 39
    -
    barcode_ean13
    -
    in file barcodes.php, method TCPDFBarcode::barcode_ean13()
        EAN13 and UPC-A barcodes.
    +
    in file barcodes.php, method TCPDFBarcode::barcode_code39()
        CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
    +
    barcode_code93
    +
    in file barcodes.php, method TCPDFBarcode::barcode_code93()
        CODE 93 - USS-93
    +
    barcode_eanext
    +
    in file barcodes.php, method TCPDFBarcode::barcode_eanext()
        UPC-Based Extentions
    +
    barcode_eanupc
    +
    in file barcodes.php, method TCPDFBarcode::barcode_eanupc()
        EAN13 and UPC-A barcodes.
    barcode_i25
    in file barcodes.php, method TCPDFBarcode::barcode_i25()
        Interleaved 2 of 5 barcodes.
    +
    barcode_msi
    +
    in file barcodes.php, method TCPDFBarcode::barcode_msi()
        MSI.
    +
    barcode_pharmacode
    +
    in file barcodes.php, method TCPDFBarcode::barcode_pharmacode()
        Pharmacode
    +
    barcode_pharmacode2t
    +
    in file barcodes.php, method TCPDFBarcode::barcode_pharmacode2t()
        Pharmacode two-track
    barcode_postnet
    -
    in file barcodes.php, method TCPDFBarcode::barcode_postnet()
        POSTNET barcodes.
    +
    in file barcodes.php, method TCPDFBarcode::barcode_postnet()
        POSTNET and PLANET barcodes.
    +
    barcode_rms4cc
    +
    in file barcodes.php, method TCPDFBarcode::barcode_rms4cc()
        RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.
    +
    barcode_s25
    +
    in file barcodes.php, method TCPDFBarcode::barcode_s25()
        Standard 2 of 5 barcodes.
    +
    binseq_to_array
    +
    in file barcodes.php, method TCPDFBarcode::binseq_to_array()
        Convert binary barcode sequence to TCPDF barcode array
    Bookmark
    in file tcpdf.php, method TCPDF::Bookmark()
    Button
    @@ -330,6 +348,10 @@
    in file tcpdf.php, method TCPDF::checkPageBreak()
        Add page if needed.
    checksum_code39
    in file barcodes.php, method TCPDFBarcode::checksum_code39()
        Calculate CODE 39 checksum (modulo 43).
    +
    checksum_code93
    +
    in file barcodes.php, method TCPDFBarcode::checksum_code93()
        Calculate CODE 93 checksum (modulo 47).
    +
    checksum_s25
    +
    in file barcodes.php, method TCPDFBarcode::checksum_s25()
        Checksum for standard 2 of 5 barcodes.
    Circle
    in file tcpdf.php, method TCPDF::Circle()
        Draws a circle.
    Clip
    @@ -1291,7 +1313,7 @@
    Write
    in file tcpdf.php, method TCPDF::Write()
        This method prints text from the current position.
    write1DBarcode
    -
    in file tcpdf.php, method TCPDF::write1DBarcode()
        Print 1D Barcode.
    +
    in file tcpdf.php, method TCPDF::write1DBarcode()
        Print a Linear Barcode.
    write2DBarcode
    in file tcpdf.php, method TCPDF::write2DBarcode()
        Print 2D Barcode.
    writeBarcode
    @@ -1337,7 +1359,7 @@ top

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/errors.html b/doc/errors.html index ca1b41d..8688995 100644 --- a/doc/errors.html +++ b/doc/errors.html @@ -35,7 +35,7 @@ Post-parsing

    - Documentation generated on Fri, 10 Apr 2009 14:17:47 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:33 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/index.html b/doc/index.html index bd37659..94606f5 100644 --- a/doc/index.html +++ b/doc/index.html @@ -58,7 +58,7 @@ This documentation was generated by phpDocumentor v1.4.1

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    diff --git a/doc/li_com-tecnick-tcpdf.html b/doc/li_com-tecnick-tcpdf.html index bd37659..94606f5 100644 --- a/doc/li_com-tecnick-tcpdf.html +++ b/doc/li_com-tecnick-tcpdf.html @@ -58,7 +58,7 @@ This documentation was generated by phpDocumentor v1.4.1

    - Documentation generated on Fri, 10 Apr 2009 14:17:41 +0200 by phpDocumentor 1.4.1 + Documentation generated on Sat, 11 Apr 2009 19:02:27 +0200 by phpDocumentor 1.4.1
    diff --git a/examples/example_027.php b/examples/example_027.php index 79dc0cc..38f9924 100755 --- a/examples/example_027.php +++ b/examples/example_027.php @@ -2,10 +2,10 @@ //============================================================+ // File name : example_027.php // Begin : 2008-03-04 -// Last Update : 2009-03-18 +// Last Update : 2009-04-11 // // Description : Example 027 for TCPDF class -// Barcodes +// 1D Barcodes // // Author: Nicola Asuni // @@ -22,7 +22,7 @@ /** * Creates an example PDF TEST document using TCPDF * @package com.tecnick.tcpdf - * @abstract TCPDF - Example: barcodes. + * @abstract TCPDF - Example: 1D Barcodes. * @author Nicola Asuni * @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @link http://tcpdf.org @@ -89,8 +89,10 @@ $style = array( 'fontsize' => 8, 'stretchtext' => 4 ); + +// PRINT VARIOUS 1D BARCODES -// CODE 39 +// CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. $pdf->write1DBarcode('CODE 39', 'C39', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); @@ -105,13 +107,33 @@ $pdf->write1DBarcode('CODE 39 E', 'C39E', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); -// CODE 39 EXTENDED with checksum +// CODE 39 EXTENDED + CHECKSUM $pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); +// CODE 93 - USS-93 +$pdf->write1DBarcode('TEST93', 'C93', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// Standard 2 of 5 +$pdf->write1DBarcode('1234567', 'S25', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// Standard 2 of 5 + CHECKSUM +$pdf->write1DBarcode('1234567', 'S25+', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + // Interleaved 2 of 5 -$pdf->write1DBarcode('12345678', 'I25', '', '', 80, 30, 0.4, $style, 'N'); +$pdf->write1DBarcode('1234567', 'I25', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// Interleaved 2 of 5 + CHECKSUM +$pdf->write1DBarcode('1234567', 'I25+', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); @@ -120,34 +142,94 @@ $pdf->write1DBarcode('CODE 128 A', 'C128A', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); -// CODE 128 A +// CODE 128 B $pdf->write1DBarcode('CODE 128 B', 'C128B', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); -// CODE 128 A +// CODE 128 C $pdf->write1DBarcode('0123456789', 'C128C', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); +// EAN 8 +$pdf->write1DBarcode('1234567', 'EAN8', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + // EAN 13 -$pdf->write1DBarcode('123456789012', 'EAN13', '', '', 80, 30, 0.4, $style, 'N'); +$pdf->write1DBarcode('1234567890128', 'EAN13', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// 2-Digits UPC-Based Extention +$pdf->write1DBarcode('34', 'EAN2', '', '', 20, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// 5-Digits UPC-Based Extention +$pdf->write1DBarcode('51234', 'EAN5', '', '', 40, 30, 0.4, $style, 'N'); $pdf->Ln(); // UPC-A -$pdf->write1DBarcode('123456789012', 'UPCA', '', '', 80, 30, 0.4, $style, 'N'); +$pdf->write1DBarcode('12345678901', 'UPCA', '', '', 80, 30, 0.4, $style, 'N'); $pdf->Ln(); -// UPC-A -$pdf->write1DBarcode('48109-1109', 'POSTNET', '', '', 80, 20, 0.4, $style, 'N'); +// UPC-E +$pdf->write1DBarcode('04210000526', 'UPCE', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// MSI +$pdf->write1DBarcode('80523', 'MSI', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// MSI + CHECKSUM (module 11) +$pdf->write1DBarcode('80523', 'MSI+', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// POSTNET +$pdf->write1DBarcode('98000', 'POSTNET', '', '', 80, 20, 0.4, $style, 'N'); + +$pdf->Ln(); + +// PLANET +$pdf->write1DBarcode('98000', 'PLANET', '', '', 80, 20, 0.4, $style, 'N'); + +$pdf->Ln(); + +// RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) +$pdf->write1DBarcode('SN34RD1A', 'RMS4CC', '', '', 80, 20, 0.4, $style, 'N'); + +$pdf->Ln(); + +// KIX (Klant index - Customer index) +$pdf->write1DBarcode('SN34RDX1A', 'KIX', '', '', 80, 20, 0.4, $style, 'N'); $pdf->Ln(); // CODABAR $pdf->write1DBarcode('123456789', 'CODABAR', '', '', 80, 30, 0.4, $style, 'N'); +$pdf->Ln(); + +// CODE 11 +$pdf->write1DBarcode('123-456-789', 'CODE11', '', '', 80, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// PHARMACODE +$pdf->write1DBarcode('789', 'PHARMA', '', '', 30, 30, 0.4, $style, 'N'); + +$pdf->Ln(); + +// PHARMACODE TWO-TRACKS +$pdf->write1DBarcode('105', 'PHARMA2T', '', '', 20, 30, 0.4, $style, 'N'); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // TEST BARCDE ALIGNMENTS diff --git a/tcpdf.php b/tcpdf.php index debd47b..7e19704 100755 --- a/tcpdf.php +++ b/tcpdf.php @@ -2,9 +2,9 @@ //============================================================+ // File name : tcpdf.php // Begin : 2002-08-03 -// Last Update : 2009-04-10 +// Last Update : 2009-04-11 // Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org -// Version : 4.5.038 +// Version : 4.5.039 // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html) // ---------------------------------------------------------------------------- // Copyright (C) 2002-2009 Nicola Asuni - Tecnick.com S.r.l. @@ -122,7 +122,7 @@ * @copyright 2002-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com * @link http://www.tcpdf.org * @license http://www.gnu.org/copyleft/lesser.html LGPL - * @version 4.5.038 + * @version 4.5.039 */ /** @@ -146,14 +146,14 @@ if (!class_exists('TCPDF', false)) { /** * define default PDF document producer */ - define('PDF_PRODUCER', 'TCPDF 4.5.038 (http://www.tcpdf.org)'); + define('PDF_PRODUCER', 'TCPDF 4.5.039 (http://www.tcpdf.org)'); /** * This is a PHP class for generating PDF documents without requiring external extensions.
    * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
    * @name TCPDF * @package com.tecnick.tcpdf - * @version 4.5.038 + * @version 4.5.039 * @author Nicola Asuni - info@tecnick.com * @link http://www.tcpdf.org * @license http://www.gnu.org/copyleft/lesser.html LGPL @@ -10083,7 +10083,7 @@ if (!class_exists('TCPDF', false)) { } /** - * Print 1D Barcode. + * Print a Linear Barcode. * @param string $code code to print * @param string $type type of barcode. * @param int $x x position in user units