Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from nreimers/php7.4-fix
Browse files Browse the repository at this point in the history
Bugfix so that it runs with PHP 7.4
  • Loading branch information
RamonSmit committed May 6, 2020
2 parents f896459 + a3ea8c1 commit f794509
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/LynX39/LaraPdfMerger/tcpdf/include/tcpdf_filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public static function decodeFilterLZWDecode($data) {
// convert string to binary string
$bitstring = '';
for ($i = 0; $i < $data_length; ++$i) {
$bitstring .= sprintf('%08b', ord($data{$i}));
$bitstring .= sprintf('%08b', ord($data[$i]));
}
// get the number of bits
$data_length = strlen($bitstring);
Expand Down Expand Up @@ -376,7 +376,7 @@ public static function decodeFilterRunLengthDecode($data) {
$i = 0;
while($i < $data_length) {
// get current byte value
$byte = ord($data{$i});
$byte = ord($data[$i]);
if ($byte == 128) {
// a length value of 128 denote EOD
break;
Expand All @@ -389,7 +389,7 @@ public static function decodeFilterRunLengthDecode($data) {
} else {
// if length is in the range 129 to 255,
// the following single byte shall be copied 257 - length (2 to 128) times during decompression
$decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
$decoded .= str_repeat($data[($i + 1)], (257 - $byte));
// move to next block
$i += 2;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LynX39/LaraPdfMerger/tcpdf/include/tcpdf_images.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public static function _parsepng($file) {
if ($n > 0) {
$trns = array();
for ($i = 0; $i < $n; ++ $i) {
$trns[] = ord($t{$i});
$trns[] = ord($t[$i]);
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/LynX39/LaraPdfMerger/tcpdf/tcpdi_parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,11 @@ protected function getRawObject($offset=0, $data=null) {
$objtype = ''; // object type to be returned
$objval = ''; // object value to be returned
// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
while (strspn($data{$offset}, "\x00\x09\x0a\x0c\x0d\x20") == 1) {
while (strspn($data[$offset], "\x00\x09\x0a\x0c\x0d\x20") == 1) {
$offset++;
}
// get first char
$char = $data{$offset};
$char = $data[$offset];
// get object type
switch ($char) {
case '%': { // \x25 PERCENT SIGN
Expand Down Expand Up @@ -744,10 +744,10 @@ protected function getRawObject($offset=0, $data=null) {
if ($char == '(') {
$open_bracket = 1;
while ($open_bracket > 0) {
if (!isset($data{$strpos})) {
if (!isset($data[$strpos])) {
break;
}
$ch = $data{$strpos};
$ch = $data[$strpos];
switch ($ch) {
case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
// skip next character
Expand Down Expand Up @@ -792,7 +792,7 @@ protected function getRawObject($offset=0, $data=null) {
}
case '<': // \x3C LESS-THAN SIGN
case '>': { // \x3E GREATER-THAN SIGN
if (isset($data{($offset + 1)}) AND ($data{($offset + 1)} == $char)) {
if (isset($data[($offset + 1)]) AND ($data[($offset + 1)] == $char)) {
// dictionary object
$objtype = PDF_TYPE_DICTIONARY;
if ($char == '<') {
Expand All @@ -815,7 +815,7 @@ protected function getRawObject($offset=0, $data=null) {
break;
}
default: {
$frag = $data{$offset} . @$data{$offset+1} . @$data{$offset+2} . @$data{$offset+3};
$frag = $data[$offset] . @$data[$offset+1] . @$data[$offset+2] . @$data[$offset+3];
switch ($frag) {
case 'endo':
// indirect object
Expand Down Expand Up @@ -892,16 +892,16 @@ private function getDictValue($offset, &$data) {
$dict = '';
$offset += 2;
do {
if ($data{$offset} == '>' && $data{$offset+1} == '>') {
if ($data[$offset] == '>' && $data[$offset+1] == '>') {
$i--;
$dict .= '>>';
$offset += 2;
} else if ($data{$offset} == '<' && $data{$offset+1} == '<') {
} else if ($data[$offset] == '<' && $data[$offset+1] == '<') {
$i++;
$dict .= '<<';
$offset += 2;
} else {
$dict .= $data{$offset};
$dict .= $data[$offset];
$offset++;
}
} while ($i>0);
Expand Down Expand Up @@ -1390,7 +1390,8 @@ private function _getPageRotation($obj) { // $obj = /Page
return false;
} else {
$res = $this->_getPageRotation($obj[1][1]['/Parent']);
if ($res[0] == PDF_TYPE_OBJECT)

if (is_array($res) && $res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
Expand Down

0 comments on commit f794509

Please sign in to comment.