From e85569fc0351501ed51643df1b12f66696727b8a Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Fri, 25 Apr 2014 19:13:02 +0100 Subject: [PATCH] 6.0.071 (2014-04-25) - Bug #911 "error with buffered png pics" was fixed. --- CHANGELOG.TXT | 3 ++ README.TXT | 4 +- composer.json | 2 +- include/barcodes/pdf417.php | 4 +- include/tcpdf_colors.php | 4 +- include/tcpdf_filters.php | 6 +-- include/tcpdf_static.php | 10 ++-- tcpdf.php | 96 ++++++++++++++++++------------------- tcpdf_barcodes_1d.php | 14 +++--- 9 files changed, 73 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 0026d81..69afb85 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.071 (2014-04-25) + - Bug #911 "error with buffered png pics" was fixed. + 6.0.070 (2014-04-24) - Bug #910 "An SVG image is being cut off (with clipping mask) when you use align options" was fixed. diff --git a/README.TXT b/README.TXT index 419e403..d30fb3c 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.070 -Release date: 2014-04-24 +Version: 6.0.071 +Release date: 2014-04-25 Author: Nicola Asuni Copyright (c) 2002-2014: diff --git a/composer.json b/composer.json index 1c0952c..c8805af 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.070", + "version": "6.0.071", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/include/barcodes/pdf417.php b/include/barcodes/pdf417.php index 4265299..f68c207 100644 --- a/include/barcodes/pdf417.php +++ b/include/barcodes/pdf417.php @@ -3,7 +3,7 @@ // File name : pdf417.php // Version : 1.0.005 // Begin : 2010-06-03 -// Last Update : 2013-09-17 +// Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- @@ -934,7 +934,7 @@ class PDF417 { $sublen = strlen($code); } if ($sublen == 6) { - $t = bcmul(''.ord($code{0}), '1099511627776'); + $t = bcmul(''.ord($code[0]), '1099511627776'); $t = bcadd($t, bcmul(''.ord($code{1}), '4294967296')); $t = bcadd($t, bcmul(''.ord($code{2}), '16777216')); $t = bcadd($t, bcmul(''.ord($code{3}), '65536')); diff --git a/include/tcpdf_colors.php b/include/tcpdf_colors.php index 10b6cef..77f1c4c 100644 --- a/include/tcpdf_colors.php +++ b/include/tcpdf_colors.php @@ -3,7 +3,7 @@ // File name : tcpdf_colors.php // Version : 1.0.004 // Begin : 2002-04-09 -// Last Update : 2014-04-10 +// Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- @@ -351,7 +351,7 @@ class TCPDF_COLORS { } return $returncolor; } - if ($color{0} != '#') { + if ($color[0] != '#') { // COLOR NAME if (isset(self::$webcolor[$color])) { // web color diff --git a/include/tcpdf_filters.php b/include/tcpdf_filters.php index 28556e4..96584db 100644 --- a/include/tcpdf_filters.php +++ b/include/tcpdf_filters.php @@ -3,7 +3,7 @@ // File name : tcpdf_filters.php // Version : 1.0.001 // Begin : 2011-05-23 -// Last Update : 2013-09-15 +// Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- @@ -320,12 +320,12 @@ class TCPDF_FILTERS { if ($index < $dix) { // index exist on dictionary $decoded .= $dictionary[$index]; - $dic_val = $dictionary[$prev_index].$dictionary[$index]{0}; + $dic_val = $dictionary[$prev_index].$dictionary[$index][0]; // store current index $prev_index = $index; } else { // index do not exist on dictionary - $dic_val = $dictionary[$prev_index].$dictionary[$prev_index]{0}; + $dic_val = $dictionary[$prev_index].$dictionary[$prev_index][0]; $decoded .= $dic_val; } // update dictionary diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 5c94e0a..d0e6253 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -3,7 +3,7 @@ // File name : tcpdf_static.php // Version : 1.0.002 // Begin : 2002-08-03 -// Last Update : 2013-09-14 +// Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.070'; + private static $tcpdf_version = '6.0.071'; /** * String alias for total number of pages. @@ -137,7 +137,7 @@ class TCPDF_STATIC { public static function set_mqr($mqr) { if (!defined('PHP_VERSION_ID')) { $version = PHP_VERSION; - define('PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4})); + define('PHP_VERSION_ID', (($version[0] * 10000) + ($version{2} * 100) + $version{4})); } if (PHP_VERSION_ID < 50300) { @set_magic_quotes_runtime($mqr); @@ -153,7 +153,7 @@ class TCPDF_STATIC { public static function get_mqr() { if (!defined('PHP_VERSION_ID')) { $version = PHP_VERSION; - define('PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4})); + define('PHP_VERSION_ID', (($version[0] * 10000) + ($version{2} * 100) + $version{4})); } if (PHP_VERSION_ID < 50300) { return @get_magic_quotes_runtime(); @@ -2165,7 +2165,7 @@ class TCPDF_STATIC { $attrib = strtolower(trim($attrib[0])); if (!empty($attrib)) { // check if matches class, id, attribute, pseudo-class or pseudo-element - switch ($attrib{0}) { + switch ($attrib[0]) { case '.': { // class if (in_array(substr($attrib, 1), $class)) { $valid = true; diff --git a/tcpdf.php b/tcpdf.php index 140ef55..0f236bf 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.070 + * @version 6.0.071 */ // 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.070 + * @version 6.0.071 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -2243,7 +2243,7 @@ class TCPDF { if (empty($orientation)) { $orientation = $default_orientation; } else { - $orientation = strtoupper($orientation{0}); + $orientation = strtoupper($orientation[0]); } if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) { $this->CurOrientation = $orientation; @@ -6819,25 +6819,30 @@ class TCPDF { // image from string $imgdata = substr($file, 1); } else { // image file - if ($file{0} === '*') { + if ($file[0] === '*') { // image as external stream $file = substr($file, 1); $exurl = $file; } - // check if is local file + // check if is a local file if (!@file_exists($file)) { - // encode spaces on filename (file is probably an URL) - $file = str_replace(' ', '%20', $file); + // try to encode spaces on filename + $tfile = str_replace(' ', '%20', $file); + if (@file_exists($tfile)) { + $file = $tfile; + } } - if (@file_exists($file)) { - // get image dimensions - $imsize = @getimagesize($file); - } - if ($imsize === FALSE) { - $imgdata = TCPDF_STATIC::fileGetContents($file); + if (($imsize = @getimagesize($file)) === FALSE) { + if (in_array($file, $this->imagekeys)) { + // get existing image data + $info = $this->getImageBuffer($file); + $imsize = array($info['w'], $info['h']); + } elseif (strpos($file, '__tcpdf_img') === FALSE) { + $imgdata = TCPDF_STATIC::fileGetContents($file); + } } } - if (isset($imgdata) AND ($imgdata !== FALSE) AND (strpos($file, '__tcpdf_img') === FALSE)) { + if (!empty($imgdata)) { // copy image to cache $original_file = $file; $file = TCPDF_STATIC::getObjFilename('img'); @@ -6911,7 +6916,7 @@ class TCPDF { // width difference $wdiff = ($oldw - $w); // horizontal alignment - switch (strtoupper($fitbox{0})) { + switch (strtoupper($fitbox[0])) { case 'L': { if ($this->rtl) { $x -= $wdiff; @@ -7017,17 +7022,12 @@ class TCPDF { $imgr = TCPDF_IMAGES::setGDImageTransparency($imgr, $img); } imagecopyresampled($imgr, $img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh); - if (($type == 'gif') OR ($type == 'png')) { - $info = TCPDF_IMAGES::_toPNG($imgr); - } else { - $info = TCPDF_IMAGES::_toJPEG($imgr, $this->jpeg_quality); - } + $img = $imgr; + } + if (($type == 'gif') OR ($type == 'png')) { + $info = TCPDF_IMAGES::_toPNG($img); } else { - if (($type == 'gif') OR ($type == 'png')) { - $info = TCPDF_IMAGES::_toPNG($img); - } else { - $info = TCPDF_IMAGES::_toJPEG($img, $this->jpeg_quality); - } + $info = TCPDF_IMAGES::_toJPEG($img, $this->jpeg_quality); } } } catch(Exception $e) { @@ -7538,7 +7538,7 @@ class TCPDF { $dest = $dest ? 'D' : 'F'; } $dest = strtoupper($dest); - if ($dest{0} != 'F') { + if ($dest[0] != 'F') { $name = preg_replace('/[\s]+/', '_', $name); $name = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $name); } @@ -8777,7 +8777,7 @@ class TCPDF { $font = file_get_contents($fontfile); $compressed = (substr($file, -2) == '.z'); if ((!$compressed) AND (isset($info['length2']))) { - $header = (ord($font{0}) == 128); + $header = (ord($font[0]) == 128); if ($header) { // strip first binary header $font = substr($font, 6); @@ -14814,7 +14814,7 @@ class TCPDF { // check page for no-write regions and adapt page margins if necessary list($x, $y) = $this->checkPageRegions($h, $x, $y); $k = $this->k; - if ($file{0} === '@') { // image from string + if ($file[0] === '@') { // image from string $data = substr($file, 1); } else { // EPS/AI file $data = TCPDF_STATIC::fileGetContents($file); @@ -14927,7 +14927,7 @@ class TCPDF { $cnt = count($lines); for ($i=0; $i < $cnt; ++$i) { $line = $lines[$i]; - if (($line == '') OR ($line{0} == '%')) { + if (($line == '') OR ($line[0] == '%')) { continue; } $len = strlen($line); @@ -16402,7 +16402,7 @@ class TCPDF { $tagname = strtolower($tag[1]); // check if we are inside a table header if ($tagname == 'thead') { - if ($element{0} == '/') { + if ($element[0] == '/') { $thead = false; } else { $thead = true; @@ -16417,7 +16417,7 @@ class TCPDF { } else { $dom[$key]['block'] = false; } - if ($element{0} == '/') { + if ($element[0] == '/') { // *** closing html tag $dom[$key]['opening'] = false; $dom[$key]['parent'] = end($level); @@ -16602,15 +16602,15 @@ class TCPDF { } // font style if (isset($dom[$key]['style']['font-weight'])) { - if (strtolower($dom[$key]['style']['font-weight']{0}) == 'n') { + if (strtolower($dom[$key]['style']['font-weight'][0]) == 'n') { if (strpos($dom[$key]['fontstyle'], 'B') !== false) { $dom[$key]['fontstyle'] = str_replace('B', '', $dom[$key]['fontstyle']); } - } elseif (strtolower($dom[$key]['style']['font-weight']{0}) == 'b') { + } elseif (strtolower($dom[$key]['style']['font-weight'][0]) == 'b') { $dom[$key]['fontstyle'] .= 'B'; } } - if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style']{0}) == 'i')) { + if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style'][0]) == 'i')) { $dom[$key]['fontstyle'] .= 'I'; } // font color @@ -16629,13 +16629,13 @@ class TCPDF { foreach ($decors as $dec) { $dec = trim($dec); if (!TCPDF_STATIC::empty_string($dec)) { - if ($dec{0} == 'u') { + if ($dec[0] == 'u') { // underline $dom[$key]['fontstyle'] .= 'U'; - } elseif ($dec{0} == 'l') { + } elseif ($dec[0] == 'l') { // line-through $dom[$key]['fontstyle'] .= 'D'; - } elseif ($dec{0} == 'o') { + } elseif ($dec[0] == 'o') { // overline $dom[$key]['fontstyle'] .= 'O'; } @@ -16654,7 +16654,7 @@ class TCPDF { } // check for text alignment if (isset($dom[$key]['style']['text-align'])) { - $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align']{0}); + $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align'][0]); } // check for CSS border properties if (isset($dom[$key]['style']['border'])) { @@ -16818,9 +16818,9 @@ class TCPDF { // font size if (isset($dom[$key]['attribute']['size'])) { if ($key > 0) { - if ($dom[$key]['attribute']['size']{0} == '+') { + if ($dom[$key]['attribute']['size'][0] == '+') { $dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] + intval(substr($dom[$key]['attribute']['size'], 1)); - } elseif ($dom[$key]['attribute']['size']{0} == '-') { + } elseif ($dom[$key]['attribute']['size'][0] == '-') { $dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] - intval(substr($dom[$key]['attribute']['size'], 1)); } else { $dom[$key]['fontsize'] = intval($dom[$key]['attribute']['size']); @@ -16862,7 +16862,7 @@ class TCPDF { if (($dom[$key]['value'] == 'pre') OR ($dom[$key]['value'] == 'tt')) { $dom[$key]['fontname'] = $this->default_monospaced_font; } - if (!empty($dom[$key]['value']) AND ($dom[$key]['value']{0} == 'h') AND (intval($dom[$key]['value']{1}) > 0) AND (intval($dom[$key]['value']{1}) < 7)) { + if (!empty($dom[$key]['value']) AND ($dom[$key]['value'][0] == 'h') AND (intval($dom[$key]['value']{1}) > 0) AND (intval($dom[$key]['value']{1}) < 7)) { // headings h1, h2, h3, h4, h5, h6 if (!isset($dom[$key]['attribute']['size']) AND !isset($dom[$key]['style']['font-size'])) { $headsize = (4 - intval($dom[$key]['value']{1})) * 2; @@ -16927,7 +16927,7 @@ class TCPDF { } // check for text alignment if (isset($dom[$key]['attribute']['align']) AND (!TCPDF_STATIC::empty_string($dom[$key]['attribute']['align'])) AND ($dom[$key]['value'] !== 'img')) { - $dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align']{0}); + $dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align'][0]); } // check for text rendering mode (the following attributes do not exist in HTML) if (isset($dom[$key]['attribute']['stroke'])) { @@ -18731,7 +18731,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } case 'img': { if (!empty($tag['attribute']['src'])) { - if ($tag['attribute']['src']{0} === '@') { + if ($tag['attribute']['src'][0] === '@') { // data stream $tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1)); $type = ''; @@ -18773,7 +18773,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $imglink = ''; if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) { $imglink = $this->HREF['url']; - if ($imglink{0} == '#') { + if ($imglink[0] == '#') { // convert url to internal link $lnkdata = explode(',', $imglink); if (isset($lnkdata[0])) { @@ -22660,7 +22660,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: // convert SVG to raster image using GD or ImageMagick libraries return $this->Image($file, $x, $y, $w, $h, 'SVG', $link, $align, true, 300, $palign, false, false, $border, false, false, false); } - if ($file{0} === '@') { // image from string + if ($file[0] === '@') { // image from string $this->svgdir = ''; $svgdata = substr($file, 1); } else { // SVG file @@ -24060,7 +24060,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $img = '@'.base64_decode(substr($img, strlen($m[0]))); } else { // fix image path - if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img{0} == '.') OR (basename($img) == $img))) { + if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) { // replace relative path with full server path $img = $this->svgdir.'/'.$img; } diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php index 83a44ec..f99dd28 100644 --- a/tcpdf_barcodes_1d.php +++ b/tcpdf_barcodes_1d.php @@ -3,7 +3,7 @@ // File name : tcpdf_barcodes_1d.php // Version : 1.0.025 // Begin : 2008-06-09 -// Last Update : 2013-03-17 +// Last Update : 2014-04-25 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- @@ -1094,7 +1094,7 @@ class TCPDFBarcode { } case 'C': { // MODE C $startid = 105; - if (ord($code{0}) == 241) { + if (ord($code[0]) == 241) { $code_data[] = 102; $code = substr($code, 1); --$len; @@ -1172,7 +1172,7 @@ class TCPDFBarcode { } case 'B': { if ($key == 0) { - $tmpchr = ord($seq[1]{0}); + $tmpchr = ord($seq[1][0]); if (($seq[2] == 1) AND ($tmpchr >= 241) AND ($tmpchr <= 244) AND isset($sequence[($key + 1)]) AND ($sequence[($key + 1)][0] != 'B')) { switch ($sequence[($key + 1)][0]) { case 'A': { @@ -1458,7 +1458,7 @@ class TCPDFBarcode { $seq .= $codes['A'][$code{$i}]; } } else { - $p = $parities[$code{0}]; + $p = $parities[$code[0]]; for ($i = 1; $i < $half_len; ++$i) { $seq .= $codes[$p[$i-1]][$code{$i}]; } @@ -1504,7 +1504,7 @@ class TCPDFBarcode { if ($len == 2) { $r = $code % 4; } elseif ($len == 5) { - $r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3})); + $r = (3 * ($code[0] + $code{2} + $code{4})) + (9 * ($code{1} + $code{3})); $r %= 10; } else { return false; @@ -1555,7 +1555,7 @@ class TCPDFBarcode { ); $p = $parities[$len][$r]; $seq = '1011'; // left guard bar - $seq .= $codes[$p[0]][$code{0}]; + $seq .= $codes[$p[0]][$code[0]]; for ($i = 1; $i < $len; ++$i) { $seq .= '01'; // separator $seq .= $codes[$p[$i]][$code{$i}]; @@ -2068,7 +2068,7 @@ class TCPDFBarcode { } } $binary_code = bcmul($binary_code, 10); - $binary_code = bcadd($binary_code, $tracking_number{0}); + $binary_code = bcadd($binary_code, $tracking_number[0]); $binary_code = bcmul($binary_code, 5); $binary_code = bcadd($binary_code, $tracking_number{1}); $binary_code .= substr($tracking_number, 2, 18);