30
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-06-06 07:40:48 +00:00

5.9.197 (2012-11-06)

- Bug item #756 "TCPDF 5.9.196 shows line on top of all PDFs" was fixed.
This commit is contained in:
Nicola Asuni 2012-11-19 22:09:33 +00:00
parent 146e4337ca
commit b73f9cbd9a
2 changed files with 79 additions and 77 deletions

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : datamatrix.php // File name : datamatrix.php
// Version : 1.0.003 // Version : 1.0.004
// Begin : 2010-06-07 // Begin : 2010-06-07
// Last Update : 2012-09-15 // Last Update : 2012-11-19
// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -34,14 +34,14 @@
//============================================================+ //============================================================+
/** /**
* @file * @file
* Class to create DataMatrix ECC 200 barcode arrays for TCPDF class. * Class to create DataMatrix ECC 200 barcode arrays for TCPDF class.
* DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code. * DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code.
* *
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 1.0.003 * @version 1.0.004
*/ */
// custom definitions // custom definitions
if (!defined('DATAMATRIXDEFS')) { if (!defined('DATAMATRIXDEFS')) {
@ -59,54 +59,54 @@ if (!defined('DATAMATRIXDEFS')) {
/** /**
* ASCII encoding: ASCII character 0 to 127 (1 byte per CW) * ASCII encoding: ASCII character 0 to 127 (1 byte per CW)
*/ */
define('ENC_ASCII', 0); define('ENC_ASCII', 0);
/** /**
* C40 encoding: Upper-case alphanumeric (3/2 bytes per CW) * C40 encoding: Upper-case alphanumeric (3/2 bytes per CW)
*/ */
define('ENC_C40', 1); define('ENC_C40', 1);
/** /**
* TEXT encoding: Lower-case alphanumeric (3/2 bytes per CW) * TEXT encoding: Lower-case alphanumeric (3/2 bytes per CW)
*/ */
define('ENC_TXT', 2); define('ENC_TXT', 2);
/** /**
* X12 encoding: ANSI X12 (3/2 byte per CW) * X12 encoding: ANSI X12 (3/2 byte per CW)
*/ */
define('ENC_X12', 3); define('ENC_X12', 3);
/** /**
* EDIFACT encoding: ASCII character 32 to 94 (4/3 bytes per CW) * EDIFACT encoding: ASCII character 32 to 94 (4/3 bytes per CW)
*/ */
define('ENC_EDF', 4); define('ENC_EDF', 4);
/** /**
* BASE 256 encoding: ASCII character 0 to 255 (1 byte per CW) * BASE 256 encoding: ASCII character 0 to 255 (1 byte per CW)
*/ */
define('ENC_BASE256', 5); define('ENC_BASE256', 5);
/** /**
* ASCII extended encoding: ASCII character 128 to 255 (1/2 byte per CW) * ASCII extended encoding: ASCII character 128 to 255 (1/2 byte per CW)
*/ */
define('ENC_ASCII_EXT', 6); define('ENC_ASCII_EXT', 6);
/** /**
* ASCII number encoding: ASCII digits (2 bytes per CW) * ASCII number encoding: ASCII digits (2 bytes per CW)
*/ */
define('ENC_ASCII_NUM', 7); define('ENC_ASCII_NUM', 7);
/** /**
* @class Datamatrix * @class Datamatrix
* Class to create DataMatrix ECC 200 barcode arrays for TCPDF class. * Class to create DataMatrix ECC 200 barcode arrays for TCPDF class.
* DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code. * DataMatrix (ISO/IEC 16022:2006) is a 2-dimensional bar code.
* *
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 1.0.003 * @version 1.0.004
*/ */
class Datamatrix { class Datamatrix {
/** /**
@ -552,7 +552,7 @@ class Datamatrix {
return ENC_C40; return ENC_C40;
} }
// get char // get char
$chr = ord($data{($pos + $charscount)}); $chr = ord($data[$pos + $charscount]);
$charscount++; $charscount++;
// STEP L // STEP L
if ($this->isCharMode($chr, ENC_ASCII_NUM)) { if ($this->isCharMode($chr, ENC_ASCII_NUM)) {
@ -709,7 +709,7 @@ class Datamatrix {
while ($pos < $data_lenght) { while ($pos < $data_lenght) {
switch ($enc) { switch ($enc) {
case ENC_ASCII: { // STEP B. While in ASCII encodation 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))) { 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))) {
// 1. If the next data sequence is at least 2 consecutive digits, encode the next two digits as a double digit in ASCII mode. // 1. If the next data sequence is at least 2 consecutive digits, encode the next two digits as a double digit in ASCII mode.
$cw[] = (intval(substr($data, $pos, 2)) + 130); $cw[] = (intval(substr($data, $pos, 2)) + 130);
++$cw_num; ++$cw_num;
@ -724,7 +724,7 @@ class Datamatrix {
++$cw_num; ++$cw_num;
} else { } else {
// get new byte // get new byte
$chr = ord($data{($pos)}); $chr = ord($data[$pos]);
++$pos; ++$pos;
if ($this->isCharMode($chr, ENC_ASCII_EXT)) { if ($this->isCharMode($chr, ENC_ASCII_EXT)) {
// 3. If the next data character is extended ASCII (greater than 127) encode it in ASCII mode first using the Upper Shift (value 235) character. // 3. If the next data character is extended ASCII (greater than 127) encode it in ASCII mode first using the Upper Shift (value 235) character.
@ -752,7 +752,7 @@ class Datamatrix {
$charset = $this->chset[$set_id]; $charset = $this->chset[$set_id];
do { do {
// 2. process the next character in C40 encodation. // 2. process the next character in C40 encodation.
$chr = ord($data{($epos)}); $chr = ord($data[$epos]);
++$epos; ++$epos;
// check for extended character // check for extended character
if ($chr & 0x80) { if ($chr & 0x80) {
@ -802,6 +802,8 @@ class Datamatrix {
$enc = $newenc; $enc = $newenc;
$cw[] = $this->getSwitchEncodingCodeword($enc); $cw[] = $this->getSwitchEncodingCodeword($enc);
++$cw_num; ++$cw_num;
$pos -= $p;
$p = 0;
break; break;
} }
} }
@ -834,9 +836,11 @@ class Datamatrix {
$cw_num += 2; $cw_num += 2;
} else { } else {
// switch to ASCII encoding // switch to ASCII encoding
$enc = ENC_ASCII; if ($enc != ENC_ASCII) {
$cw[] = $this->getSwitchEncodingCodeword($enc); $enc = ENC_ASCII;
++$cw_num; $cw[] = $this->getSwitchEncodingCodeword($enc);
++$cw_num;
}
} }
} }
break; break;
@ -846,52 +850,50 @@ class Datamatrix {
$temp_cw = array(); $temp_cw = array();
$epos = $pos; $epos = $pos;
$field_lenght = 0; $field_lenght = 0;
while ($epos < $data_lenght) { $newenc = $enc;
do {
// 2. process the next character in EDIFACT encodation. // 2. process the next character in EDIFACT encodation.
$chr = ord($data{($epos)}); $chr = ord($data[$epos]);
++$epos; if ($this->isCharMode($chr, ENC_EDF)) {
$temp_cw[] = $chr; ++$epos;
++$field_lenght; $temp_cw[] = $chr;
if (($field_lenght == 4) OR ($epos == $data_lenght)) { ++$field_lenght;
if ($field_lenght < 4) { }
if (($field_lenght == 4) OR ($epos == $data_lenght) OR !$this->isCharMode($chr, ENC_EDF)) {
if ($field_lenght < 4) { echo $field_lenght."\n";
// set unlatch character // set unlatch character
$temp_cw[] = 0x1f; $temp_cw[] = 0x1f;
++$field_lenght; ++$field_lenght;
$enc = ENC_ASCII;
// fill empty characters // fill empty characters
for ($i = $field_lenght; $i < 4; ++$i) { for ($i = $field_lenght; $i < 4; ++$i) {
$temp_cw[] = 0; $temp_cw[] = 0;
} }
$enc = ENC_ASCII;
} }
// encodes four data characters in three codewords // encodes four data characters in three codewords
$cw[] = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4); $tcw = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4);
$cw[] = (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2); if ($tcw > 0) {
$cw[] = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F); $cw[] = $tcw;
$cw_num += 3; $cw_num++;
}
$tcw= (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2);
if ($tcw > 0) {
$cw[] = $tcw;
$cw_num++;
}
$tcw = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F);
if ($tcw > 0) {
$cw[] = $tcw;
$cw_num++;
}
$temp_cw = array(); $temp_cw = array();
$pos = $epos; $pos = $epos;
$field_lenght = 0; $field_lenght = 0;
} if ($enc == ENC_ASCII) {
}
// 1. If the EDIFACT encoding is at the point of starting a new triple symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode.
if ($field_lenght == 0) {
// get remaining number of data symbols
$cwr = ($this->getMaxDataCodewords($cw_num + 2) - $cw_num);
if ($cwr < 3) {
// return to ascii without unlatch
$enc = ENC_ASCII;
break; // exit from EDIFACT mode
} else {
$newenc = $this->lookAheadTest($data, $pos, $enc);
if ($newenc != $enc) {
// 1. If the look-ahead test (starting at step J) indicates another mode, switch to that mode.
$enc = $newenc;
$cw[] = $this->getSwitchEncodingCodeword($enc);
++$cw_num;
break; // exit from EDIFACT mode break; // exit from EDIFACT mode
} }
} }
} } while ($epos < $data_lenght);
break; break;
} }
case ENC_BASE256: { // G. While in Base 256 (B256) encodation case ENC_BASE256: { // G. While in Base 256 (B256) encodation
@ -908,7 +910,7 @@ class Datamatrix {
break; // exit from B256 mode break; // exit from B256 mode
} else { } else {
// 2. Otherwise, process the next character in Base 256 encodation. // 2. Otherwise, process the next character in Base 256 encodation.
$chr = ord($data{($pos)}); $chr = ord($data[$pos]);
++$pos; ++$pos;
$temp_cw[] = $chr; $temp_cw[] = $chr;
++$field_lenght; ++$field_lenght;

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 5.9.197 // Version : 5.9.198
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2012-11-06 // Last Update : 2012-11-19
// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -139,7 +139,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p> * Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 5.9.197 * @version 5.9.198
*/ */
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@ -151,7 +151,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.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.<br> * 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.<br>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions. * @brief PHP class for generating PDF documents without requiring external extensions.
* @version 5.9.197 * @version 5.9.198
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -162,7 +162,7 @@ class TCPDF {
* Current TCPDF version. * Current TCPDF version.
* @private * @private
*/ */
private $tcpdf_version = '5.9.197'; private $tcpdf_version = '5.9.198';
// Protected properties // Protected properties