Update TCPDF.

This commit is contained in:
Nate
2019-10-22 12:52:52 -06:00
parent 679c78d269
commit 663d2cb63e
202 changed files with 62215 additions and 2013 deletions
+23 -23
View File
@@ -710,13 +710,13 @@ class Datamatrix {
$pos = 0; // current position
$cw = array(); // array of codewords to be returned
$cw_num = 0; // number of data codewords
$data_lenght = strlen($data); // number of chars
while ($pos < $data_lenght) {
$data_length = strlen($data); // number of chars
while ($pos < $data_length) {
// 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))) {
if (($data_length > 1) AND ($pos < ($data_length - 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.
$cw[] = (intval(substr($data, $pos, 2)) + 130);
++$cw_num;
@@ -820,7 +820,7 @@ class Datamatrix {
break;
}
}
} while (($p > 0) AND ($epos < $data_lenght));
} while (($p > 0) AND ($epos < $data_length));
// process last data (if any)
if ($p > 0) {
// get remaining number of data symbols
@@ -870,10 +870,10 @@ class Datamatrix {
break;
}
case ENC_EDF: { // F. While in EDIFACT (EDF) encodation
// initialize temporary array with 0 lenght
// initialize temporary array with 0 length
$temp_cw = array();
$epos = $pos;
$field_lenght = 0;
$field_length = 0;
$newenc = $enc;
do {
// 2. process the next character in EDIFACT encodation.
@@ -881,21 +881,21 @@ class Datamatrix {
if ($this->isCharMode($chr, ENC_EDF)) {
++$epos;
$temp_cw[] = $chr;
++$field_lenght;
++$field_length;
}
if (($field_lenght == 4) OR ($epos == $data_lenght) OR !$this->isCharMode($chr, ENC_EDF)) {
if (($epos == $data_lenght) AND ($field_lenght < 3)) {
if (($field_length == 4) OR ($epos == $data_length) OR !$this->isCharMode($chr, ENC_EDF)) {
if (($epos == $data_length) AND ($field_length < 3)) {
$enc = ENC_ASCII;
$cw[] = $this->getSwitchEncodingCodeword($enc);
++$cw_num;
break;
}
if ($field_lenght < 4) {
if ($field_length < 4) {
// set unlatch character
$temp_cw[] = 0x1f;
++$field_lenght;
++$field_length;
// fill empty characters
for ($i = $field_lenght; $i < 4; ++$i) {
for ($i = $field_length; $i < 4; ++$i) {
$temp_cw[] = 0;
}
$enc = ENC_ASCII;
@@ -919,19 +919,19 @@ class Datamatrix {
}
$temp_cw = array();
$pos = $epos;
$field_lenght = 0;
$field_length = 0;
if ($enc == ENC_ASCII) {
break; // exit from EDIFACT mode
}
}
} while ($epos < $data_lenght);
} while ($epos < $data_length);
break;
}
case ENC_BASE256: { // G. While in Base 256 (B256) encodation
// initialize temporary array with 0 lenght
// initialize temporary array with 0 length
$temp_cw = array();
$field_lenght = 0;
while (($pos < $data_lenght) AND ($field_lenght <= 1555)) {
$field_length = 0;
while (($pos < $data_length) AND ($field_length <= 1555)) {
$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.
@@ -942,16 +942,16 @@ class Datamatrix {
$chr = ord($data[$pos]);
++$pos;
$temp_cw[] = $chr;
++$field_lenght;
++$field_length;
}
}
// set field lenght
if ($field_lenght <= 249) {
$cw[] = $this->get255StateCodeword($field_lenght, ($cw_num + 1));
// set field length
if ($field_length <= 249) {
$cw[] = $this->get255StateCodeword($field_length, ($cw_num + 1));
++$cw_num;
} else {
$cw[] = $this->get255StateCodeword((floor($field_lenght / 250) + 249), ($cw_num + 1));
$cw[] = $this->get255StateCodeword(($field_lenght % 250), ($cw_num + 2));
$cw[] = $this->get255StateCodeword((floor($field_length / 250) + 249), ($cw_num + 1));
$cw[] = $this->get255StateCodeword(($field_length % 250), ($cw_num + 2));
$cw_num += 2;
}
if (!empty($temp_cw)) {
+12 -12
View File
@@ -636,7 +636,7 @@ class PDF417 {
// add macro section
$codewords = array_merge($codewords, $macrocw);
}
// Symbol Lenght Descriptor (number of data codewords including Symbol Lenght Descriptor and pad codewords)
// Symbol Length Descriptor (number of data codewords including Symbol Length Descriptor and pad codewords)
$sld = $size - $errsize;
// add symbol length description
array_unshift($codewords, $sld);
@@ -740,16 +740,6 @@ class PDF417 {
* @protected
*/
protected function getErrorCorrectionLevel($ecl, $numcw) {
// get maximum correction level
$maxecl = 8; // starting error level
$maxerrsize = (928 - $numcw); // available codewords for error
while ($maxecl > 0) {
$errsize = (2 << $ecl);
if ($maxerrsize >= $errsize) {
break;
}
--$maxecl;
}
// check for automatic levels
if (($ecl < 0) OR ($ecl > 8)) {
if ($numcw < 41) {
@@ -764,6 +754,16 @@ class PDF417 {
$ecl = $maxecl;
}
}
// get maximum correction level
$maxecl = 8; // starting error level
$maxerrsize = (928 - $numcw); // available codewords for error
while ($maxecl > 0) {
$errsize = (2 << $ecl);
if ($maxerrsize >= $errsize) {
break;
}
--$maxecl;
}
if ($ecl > $maxecl) {
$ecl = $maxecl;
}
@@ -772,7 +772,7 @@ class PDF417 {
/**
* Returns the error correction codewords
* @param $cw (array) array of codewords including Symbol Lenght Descriptor and pad
* @param $cw (array) array of codewords including Symbol Length Descriptor and pad
* @param $ecl (int) error correction level 0-8
* @return array of error correction codewords
* @protected
@@ -720,6 +720,7 @@ class QRcode {
protected function encodeMask($mask) {
$spec = array(0, 0, 0, 0, 0);
$this->datacode = $this->getByteStream($this->items);
if (is_null($this->datacode)) {
return NULL;
}