From 5cee42b643ef58446dc1c06fb8bfee73feaf280a Mon Sep 17 00:00:00 2001 From: Wojtek Date: Mon, 19 Sep 2016 12:50:35 +0100 Subject: [PATCH 1/2] Removed start/stop code from barcode label --- tcpdf_barcodes_1d.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php index 0c389ae..fc52dec 100644 --- a/tcpdf_barcodes_1d.php +++ b/tcpdf_barcodes_1d.php @@ -912,9 +912,14 @@ protected function barcode_i25($code, $checksum=false) { // add leading zero if code-length is odd $code = '0'.$code; } + // add start and stop codes $code = 'AA'.strtolower($code).'ZA'; - + + $cleanCode = str_replace(array('AA', 'ZA'), '', $code); + + $bararray = array('code' => $cleanCode, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); $k = 0; $clen = strlen($code); From 2e2b596ae548e528d5b5b7d68269e66dfb85f6f5 Mon Sep 17 00:00:00 2001 From: Wojtek Date: Thu, 22 Sep 2016 14:09:12 +0100 Subject: [PATCH 2/2] Remove leading zero from barcode label --- tcpdf_barcodes_1d.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php index fc52dec..1cb2545 100644 --- a/tcpdf_barcodes_1d.php +++ b/tcpdf_barcodes_1d.php @@ -1365,11 +1365,16 @@ protected function barcode_eanupc($code, $len=13) { // wrong checkdigit return false; } + if ($len == 12) { + // UPC-A - $code = '0'.$code; + $upca = true; + $code = '0'.$code; ++$len; + } + if ($upce) { // convert UPC-A to UPC-E $tmp = substr($code, 4, 3); @@ -1469,14 +1474,27 @@ protected function barcode_eanupc($code, $len=13) { $k = 0; $seq = '101'; // left guard bar if ($upce) { - $bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $clean_code = substr($upce_code, 1); + $bararray = array('code' => $clean_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()); + + if($upca === true) { + + $clean_code = substr($code, 1); + + } else { + + $clean_code = $code; + + } + + $bararray = array('code' => $clean_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); + $half_len = intval(ceil($len / 2)); if ($len == 8) { for ($i = 0; $i < $half_len; ++$i) {