diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 50bbfea..56b791c 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.068 (2014-04-22) + - Some Datamatrix barcode bugs were fixed. + 6.0.067 (2014-04-21) - startLayer() method signature was changed to include a new "lock" parameter. diff --git a/README.TXT b/README.TXT index e82f382..cf9c24d 100644 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.067 -Release date: 2014-04-21 +Version: 6.0.063 +Release date: 2014-04-22 Author: Nicola Asuni Copyright (c) 2002-2014: diff --git a/composer.json b/composer.json index 19b5294..f3181a3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.067", + "version": "6.0.063", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/include/barcodes/datamatrix.php b/include/barcodes/datamatrix.php index 95e4cbb..4092f61 100644 --- a/include/barcodes/datamatrix.php +++ b/include/barcodes/datamatrix.php @@ -1,13 +1,13 @@ $nd) { // add padding - if ($this->last_enc == ENC_EDF) { - // switch to ASCII encoding - $cw[] = 124; - ++$nd; - } elseif (($this->last_enc != ENC_ASCII) AND ($this->last_enc != ENC_BASE256)) { - // switch to ASCII encoding - $cw[] = 254; - ++$nd; + if ((($params[11] - $nd) > 1) AND ($cw[($nd - 1)] != 254)) { + if ($this->last_enc == ENC_EDF) { + // switch to ASCII encoding + $cw[] = 124; + ++$nd; + } elseif (($this->last_enc != ENC_ASCII) AND ($this->last_enc != ENC_BASE256)) { + // switch to ASCII encoding + $cw[] = 254; + ++$nd; + } } if ($params[11] > $nd) { // add first pad @@ -652,6 +654,9 @@ class Datamatrix { switch ($mode) { case ENC_ASCII: { // ASCII character 0 to 127 $cw = 254; + if ($this->last_enc == ENC_EDF) { + $cw = 124; + } break; } case ENC_C40: { // Upper-case alphanumeric @@ -707,6 +712,8 @@ class Datamatrix { $cw_num = 0; // number of data codewords $data_lenght = strlen($data); // number of chars while ($pos < $data_lenght) { + // set last used encoding + $this->last_enc = $enc; switch ($enc) { case ENC_ASCII: { // STEP B. While in ASCII encodation if (($data_lenght > 1) AND ($pos < ($data_lenght - 1)) AND ($this->isCharMode(ord($data[$pos]), ENC_ASCII_NUM) AND $this->isCharMode(ord($data[$pos + 1]), ENC_ASCII_NUM))) { @@ -799,7 +806,13 @@ class Datamatrix { // 1. If the C40 encoding is at the point of starting a new double symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode. $newenc = $this->lookAheadTest($data, $pos, $enc); if ($newenc != $enc) { + // switch to new encoding $enc = $newenc; + if ($enc != ENC_ASCII) { + // set unlatch character + $cw[] = $this->getSwitchEncodingCodeword(ENC_ASCII); + ++$cw_num; + } $cw[] = $this->getSwitchEncodingCodeword($enc); ++$cw_num; $pos -= $p; @@ -811,20 +824,22 @@ class Datamatrix { // process last data (if any) if ($p > 0) { // get remaining number of data symbols - $cwr = ($this->getMaxDataCodewords($cw_num + 2) - $cw_num); + $cwr = ($this->getMaxDataCodewords($cw_num) - $cw_num); if (($cwr == 1) AND ($p == 1)) { // d. If one symbol character remains and one C40 value (data character) remains to be encoded $c1 = array_shift($temp_cw); --$p; - $cw[] = ($c1 + 1); + $cw[] = ($chr + 1); ++$cw_num; + $pos = $epos; } elseif (($cwr == 2) AND ($p == 1)) { // c. If two symbol characters remain and only one C40 value (data character) remains to be encoded $c1 = array_shift($temp_cw); --$p; $cw[] = 254; - $cw[] = ($c1 + 1); + $cw[] = ($chr + 1); $cw_num += 2; + $pos = $epos; } elseif (($cwr == 2) AND ($p == 2)) { // b. If two symbol characters remain and two C40 values remain to be encoded $c1 = array_shift($temp_cw); @@ -834,12 +849,14 @@ class Datamatrix { $cw[] = ($tmp >> 8); $cw[] = ($tmp % 256); $cw_num += 2; + $pos = $epos; } else { // switch to ASCII encoding if ($enc != ENC_ASCII) { $enc = ENC_ASCII; $cw[] = $this->getSwitchEncodingCodeword($enc); ++$cw_num; + $pos = ($epos - $p); } } } @@ -862,6 +879,8 @@ class Datamatrix { if (($field_lenght == 4) OR ($epos == $data_lenght) OR !$this->isCharMode($chr, ENC_EDF)) { if (($epos == $data_lenght) AND ($field_lenght < 3)) { $enc = ENC_ASCII; + $cw[] = $this->getSwitchEncodingCodeword($enc); + ++$cw_num; break; } if ($field_lenght < 4) { @@ -873,6 +892,7 @@ class Datamatrix { $temp_cw[] = 0; } $enc = ENC_ASCII; + $this->last_enc = $enc; } // encodes four data characters in three codewords $tcw = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4); @@ -939,8 +959,6 @@ class Datamatrix { } } // end of switch enc } // end of while - // set last used encoding - $this->last_enc = $enc; return $cw; } diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 985a964..61cf0e3 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.067'; + private static $tcpdf_version = '6.0.068'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index daf4575..5ae1f59 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.067 + * @version 6.0.068 */ // TCPDF configuration @@ -128,7 +128,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php'); * 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.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.0.067 + * @version 6.0.068 * @author Nicola Asuni - info@tecnick.com */ class TCPDF {