Update tcpdf to 6.2.26

This commit is contained in:
Laurent Destailleur 2019-02-12 03:32:22 +01:00
parent f69f574eff
commit 8ca939d2c1
8 changed files with 6919 additions and 217 deletions

View File

@ -1,5 +1,17 @@
Unreleased 6.2.25
- fix Undesired mouseover effect on links in PDF on Chrome Pdf Viewer - Fix support for image URLs.
6.2.24
- Support remote urls when checking if file exists.
6.2.23
- Simplify file_exists function.
6.2.22
- Fix for security vulnerability: Using the phar:// wrapper it was possible to trigger the unserialization of user provided data.
6.2.19
- Merge various fixes for PHP 7.3 compatibility and security.
6.2.13 (2016-06-10) 6.2.13 (2016-06-10)
- IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable. - IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable.

View File

@ -1,47 +1,46 @@
{ {
"name": "tecnickcom/tcpdf", "name" : "tecnickcom/tcpdf",
"version": "6.2.17", "version" : "6.2.26",
"homepage": "http://www.tcpdf.org/", "homepage" : "http://www.tcpdf.org/",
"type": "library", "type" : "library",
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.", "description" : "TCPDF is a PHP class for generating PDF documents and barcodes.",
"keywords": [ "keywords" : [
"PDF", "PDF",
"tcpdf", "tcpdf",
"PDFD32000-2008", "PDFD32000-2008",
"qrcode", "qrcode",
"datamatrix", "datamatrix",
"pdf417", "pdf417",
"barcodes" "barcodes"
], ],
"license": "LGPL-3.0", "license" : "LGPL-3.0",
"authors": [ "authors" : [{
{ "name" : "Nicola Asuni",
"name": "Nicola Asuni", "email" : "info@tecnick.com",
"email": "info@tecnick.com", "role" : "lead"
"role": "lead" }
} ],
], "require" : {
"require": { "php" : ">=5.3.0"
"php": ">=5.3.0" },
}, "autoload" : {
"autoload": { "classmap" : [
"classmap": [ "config",
"config", "include",
"include", "tcpdf.php",
"tcpdf.php", "tcpdf_parser.php",
"tcpdf_parser.php", "tcpdf_import.php",
"tcpdf_import.php", "tcpdf_barcodes_1d.php",
"tcpdf_barcodes_1d.php", "tcpdf_barcodes_2d.php",
"tcpdf_barcodes_2d.php", "include/tcpdf_colors.php",
"include/tcpdf_colors.php", "include/tcpdf_filters.php",
"include/tcpdf_filters.php", "include/tcpdf_font_data.php",
"include/tcpdf_font_data.php", "include/tcpdf_fonts.php",
"include/tcpdf_fonts.php", "include/tcpdf_images.php",
"include/tcpdf_images.php", "include/tcpdf_static.php",
"include/tcpdf_static.php", "include/barcodes/datamatrix.php",
"include/barcodes/datamatrix.php", "include/barcodes/pdf417.php",
"include/barcodes/pdf417.php", "include/barcodes/qrcode.php"
"include/barcodes/qrcode.php" ]
] }
}
} }

View File

@ -70,7 +70,7 @@ class TCPDF_FONTS {
* @public static * @public static
*/ */
public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) { public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) {
if (!file_exists($fontfile)) { if (!TCPDF_STATIC::file_exists($fontfile)) {
// Could not find file // Could not find file
return false; return false;
} }
@ -95,7 +95,7 @@ class TCPDF_FONTS {
$outpath = self::_getfontpath(); $outpath = self::_getfontpath();
} }
// check if this font already exist // check if this font already exist
if (@file_exists($outpath.$font_name.'.php')) { if (@TCPDF_STATIC::file_exists($outpath.$font_name.'.php')) {
// this font already exist (delete it from fonts folder to rebuild it) // this font already exist (delete it from fonts folder to rebuild it)
return $font_name; return $font_name;
} }
@ -1543,11 +1543,11 @@ class TCPDF_FONTS {
public static function getFontFullPath($file, $fontdir=false) { public static function getFontFullPath($file, $fontdir=false) {
$fontfile = ''; $fontfile = '';
// search files on various directories // search files on various directories
if (($fontdir !== false) AND @file_exists($fontdir.$file)) { if (($fontdir !== false) AND @TCPDF_STATIC::file_exists($fontdir.$file)) {
$fontfile = $fontdir.$file; $fontfile = $fontdir.$file;
} elseif (@file_exists(self::_getfontpath().$file)) { } elseif (@TCPDF_STATIC::file_exists(self::_getfontpath().$file)) {
$fontfile = self::_getfontpath().$file; $fontfile = self::_getfontpath().$file;
} elseif (@file_exists($file)) { } elseif (@TCPDF_STATIC::file_exists($file)) {
$fontfile = $file; $fontfile = $file;
} }
return $fontfile; return $fontfile;
@ -2003,7 +2003,11 @@ class TCPDF_FONTS {
$chars = str_split($str); $chars = str_split($str);
$carr = array_map('ord', $chars); $carr = array_map('ord', $chars);
} }
$currentfont['subsetchars'] += array_fill_keys($carr, true); if (is_array($currentfont['subsetchars']) && is_array($carr)) {
$currentfont['subsetchars'] += array_fill_keys($carr, true);
} else {
$currentfont['subsetchars'] = array_merge($currentfont['subsetchars'], $carr);
}
return $carr; return $carr;
} }

View File

@ -161,12 +161,8 @@ class TCPDF_IMAGES {
*/ */
public static function _parsejpeg($file) { public static function _parsejpeg($file) {
// check if is a local file // check if is a local file
if (!@file_exists($file)) { if (!@TCPDF_STATIC::file_exists($file)) {
// try to encode spaces on filename return false;
$tfile = str_replace(' ', '%20', $file);
if (@file_exists($tfile)) {
$file = $tfile;
}
} }
$a = getimagesize($file); $a = getimagesize($file);
if (empty($a)) { if (empty($a)) {

View File

@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version. * Current TCPDF version.
* @private static * @private static
*/ */
private static $tcpdf_version = '6.2.17'; private static $tcpdf_version = '6.2.26';
/** /**
* String alias for total number of pages. * String alias for total number of pages.
@ -1774,39 +1774,6 @@ class TCPDF_STATIC {
return $angle; return $angle;
} }
// ====================================================================================================================
// REIMPLEMENTED
// ====================================================================================================================
/** /**
* Split string by a regular expression. * Split string by a regular expression.
* This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850 * This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
@ -1854,6 +1821,49 @@ class TCPDF_STATIC {
return fopen($filename, $mode); return fopen($filename, $mode);
} }
/**
* Check if the URL exist.
* @param url (string) URL to check.
* @return Returns TRUE if the URL exists; FALSE otherwise.
* @public static
*/
public static function url_exists($url) {
$crs = curl_init();
curl_setopt($crs, CURLOPT_URL, $url);
curl_setopt($crs, CURLOPT_NOBODY, true);
curl_setopt($crs, CURLOPT_FAILONERROR, true);
if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($crs, CURLOPT_TIMEOUT, 30);
curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
curl_exec($crs);
$code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
curl_close($crs);
return ($code == 200);
}
/**
* Wrapper for file_exists.
* Checks whether a file or directory exists.
* Only allows some protocols and local files.
* @param filename (string) Path to the file or directory.
* @return Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
* @public static
*/
public static function file_exists($filename) {
if (preg_match('|^https?://|', $filename) == 1) {
return self::url_exists($filename);
}
if (strpos($filename, '://')) {
return false; // only support http and https wrappers for security reasons
}
return @file_exists($filename);
}
/** /**
* Reads entire file into a string. * Reads entire file into a string.
* The file can be also an URL. * The file can be also an URL.
@ -1914,8 +1924,10 @@ class TCPDF_STATIC {
} }
// //
$alt = array_unique($alt); $alt = array_unique($alt);
//var_dump($alt);exit;//DEBUG
foreach ($alt as $path) { foreach ($alt as $path) {
if (!self::file_exists($path)) {
return false;
}
$ret = @file_get_contents($path); $ret = @file_get_contents($path);
if ($ret !== false) { if ($ret !== false) {
return $ret; return $ret;
@ -1949,8 +1961,6 @@ class TCPDF_STATIC {
return false; return false;
} }
/** /**
* Get ULONG from string (Big Endian 32-bit unsigned integer). * Get ULONG from string (Big Endian 32-bit unsigned integer).
* @param $str (string) string from where to extract value * @param $str (string) string from where to extract value

View File

@ -1,13 +1,13 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 6.2.13 // Version : 6.2.26
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2015-06-18 // Last Update : 2018-09-14
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - 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)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD // Copyright (C) 2002-2018 Nicola Asuni - Tecnick.com LTD
// //
// This file is part of TCPDF software library. // This file is part of TCPDF software library.
// //
@ -104,7 +104,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 6.2.8 * @version 6.2.26
*/ */
// TCPDF configuration // TCPDF configuration
@ -128,8 +128,11 @@ 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.<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 6.2.8 * @version 6.2.26
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
* @IgnoreAnnotation("protected")
* @IgnoreAnnotation("public")
* @IgnoreAnnotation("pre")
*/ */
class TCPDF { class TCPDF {
@ -1994,10 +1997,6 @@ class TCPDF {
* @since 1.53.0.TC016 * @since 1.53.0.TC016
*/ */
public function __destruct() { public function __destruct() {
// restore internal encoding
if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
mb_internal_encoding($this->internal_encoding);
}
// cleanup // cleanup
$this->_destroy(true); $this->_destroy(true);
} }
@ -4257,7 +4256,7 @@ class TCPDF {
// true when the font style variation is missing // true when the font style variation is missing
$missing_style = false; $missing_style = false;
// search and include font file // search and include font file
if (TCPDF_STATIC::empty_string($fontfile) OR (!@file_exists($fontfile))) { if (TCPDF_STATIC::empty_string($fontfile) OR (!@TCPDF_STATIC::file_exists($fontfile))) {
// build a standard filenames for specified font // build a standard filenames for specified font
$tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php'; $tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php';
$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir); $fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
@ -4269,7 +4268,7 @@ class TCPDF {
} }
} }
// include font file // include font file
if (!TCPDF_STATIC::empty_string($fontfile) AND (@file_exists($fontfile))) { if (!TCPDF_STATIC::empty_string($fontfile) AND (@TCPDF_STATIC::file_exists($fontfile))) {
include($fontfile); include($fontfile);
} else { } else {
$this->Error('Could not include font definition file: '.$family.''); $this->Error('Could not include font definition file: '.$family.'');
@ -4453,6 +4452,7 @@ class TCPDF {
* @see SetFont() * @see SetFont()
*/ */
public function SetFontSize($size, $out=true) { public function SetFontSize($size, $out=true) {
$size = (float)$size;
// font size in points // font size in points
$this->FontSizePt = $size; $this->FontSizePt = $size;
// font size in user units // font size in user units
@ -4809,19 +4809,19 @@ class TCPDF {
$this->PageAnnots[$page][] = array('n' => ++$this->n, 'x' => $x, 'y' => $y, 'w' => $w, 'h' => $h, 'txt' => $text, 'opt' => $opt, 'numspaces' => $spaces); $this->PageAnnots[$page][] = array('n' => ++$this->n, 'x' => $x, 'y' => $y, 'w' => $w, 'h' => $h, 'txt' => $text, 'opt' => $opt, 'numspaces' => $spaces);
if (!$this->pdfa_mode) { if (!$this->pdfa_mode) {
if ((($opt['Subtype'] == 'FileAttachment') OR ($opt['Subtype'] == 'Sound')) AND (!TCPDF_STATIC::empty_string($opt['FS'])) if ((($opt['Subtype'] == 'FileAttachment') OR ($opt['Subtype'] == 'Sound')) AND (!TCPDF_STATIC::empty_string($opt['FS']))
AND (@file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS'])) AND (@TCPDF_STATIC::file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS']))
AND (!isset($this->embeddedfiles[basename($opt['FS'])]))) { AND (!isset($this->embeddedfiles[basename($opt['FS'])]))) {
$this->embeddedfiles[basename($opt['FS'])] = array('f' => ++$this->n, 'n' => ++$this->n, 'file' => $opt['FS']); $this->embeddedfiles[basename($opt['FS'])] = array('f' => ++$this->n, 'n' => ++$this->n, 'file' => $opt['FS']);
} }
} }
// Add widgets annotation's icons // Add widgets annotation's icons
if (isset($opt['mk']['i']) AND @file_exists($opt['mk']['i'])) { if (isset($opt['mk']['i']) AND @TCPDF_STATIC::file_exists($opt['mk']['i'])) {
$this->Image($opt['mk']['i'], '', '', 10, 10, '', '', '', false, 300, '', false, false, 0, false, true); $this->Image($opt['mk']['i'], '', '', 10, 10, '', '', '', false, 300, '', false, false, 0, false, true);
} }
if (isset($opt['mk']['ri']) AND @file_exists($opt['mk']['ri'])) { if (isset($opt['mk']['ri']) AND @TCPDF_STATIC::file_exists($opt['mk']['ri'])) {
$this->Image($opt['mk']['ri'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true); $this->Image($opt['mk']['ri'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true);
} }
if (isset($opt['mk']['ix']) AND @file_exists($opt['mk']['ix'])) { if (isset($opt['mk']['ix']) AND @TCPDF_STATIC::file_exists($opt['mk']['ix'])) {
$this->Image($opt['mk']['ix'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true); $this->Image($opt['mk']['ix'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true);
} }
} }
@ -5769,10 +5769,9 @@ class TCPDF {
$this->resetLastH(); $this->resetLastH();
} }
if (!TCPDF_STATIC::empty_string($y)) { if (!TCPDF_STATIC::empty_string($y)) {
$this->SetY($y); $this->SetY($y); // set y in order to convert negative y values to positive ones
} else {
$y = $this->GetY();
} }
$y = $this->GetY();
$resth = 0; $resth = 0;
if (($h > 0) AND $this->inPageBody() AND (($y + $h + $mc_margin['T'] + $mc_margin['B']) > $this->PageBreakTrigger)) { if (($h > 0) AND $this->inPageBody() AND (($y + $h + $mc_margin['T'] + $mc_margin['B']) > $this->PageBreakTrigger)) {
// spit cell in more pages/columns // spit cell in more pages/columns
@ -6845,13 +6844,9 @@ class TCPDF {
$file = substr($file, 1); $file = substr($file, 1);
$exurl = $file; $exurl = $file;
} }
// check if is a local file // check if file exist and it is valid
if (!@file_exists($file)) { if (!@TCPDF_STATIC::file_exists($file)) {
// try to encode spaces on filename return false;
$tfile = str_replace(' ', '%20', $file);
if (@file_exists($tfile)) {
$file = $tfile;
}
} }
if (($imsize = @getimagesize($file)) === FALSE) { if (($imsize = @getimagesize($file)) === FALSE) {
if (in_array($file, $this->imagekeys)) { if (in_array($file, $this->imagekeys)) {
@ -7750,6 +7745,10 @@ class TCPDF {
* @since 4.5.016 (2009-02-24) * @since 4.5.016 (2009-02-24)
*/ */
public function _destroy($destroyall=false, $preserve_objcopy=false) { public function _destroy($destroyall=false, $preserve_objcopy=false) {
// restore internal encoding
if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
mb_internal_encoding($this->internal_encoding);
}
if ($destroyall AND !$preserve_objcopy) { if ($destroyall AND !$preserve_objcopy) {
// remove all temporary files // remove all temporary files
$tmpfiles = glob(K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_*'); $tmpfiles = glob(K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_*');
@ -9648,7 +9647,7 @@ class TCPDF {
protected function _putcatalog() { protected function _putcatalog() {
// put XMP // put XMP
$xmpobj = $this->_putXMP(); $xmpobj = $this->_putXMP();
// if required, add standard sRGB_IEC61966-2.1 blackscaled ICC colour profile // if required, add standard sRGB ICC colour profile
if ($this->pdfa_mode OR $this->force_srgb) { if ($this->pdfa_mode OR $this->force_srgb) {
$iccobj = $this->_newobj(); $iccobj = $this->_newobj();
$icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc'); $icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc');
@ -18318,7 +18317,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
// text // text
$this->htmlvspace = 0; $this->htmlvspace = 0;
if ((!$this->premode) AND $this->isRTLTextDir()) { $isRTLString = preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $dom[$key]['value']) || preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $dom[$key]['value']);
if ((!$this->premode) AND $this->isRTLTextDir() AND !$isRTLString) {
// reverse spaces order // reverse spaces order
$lsp = ''; // left spaces $lsp = ''; // left spaces
$rsp = ''; // right spaces $rsp = ''; // right spaces
@ -18333,7 +18333,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
if ($newline) { if ($newline) {
if (!$this->premode) { if (!$this->premode) {
$prelen = strlen($dom[$key]['value']); $prelen = strlen($dom[$key]['value']);
if ($this->isRTLTextDir()) { if ($this->isRTLTextDir() AND !$isRTLString) {
// right trim except non-breaking space // right trim except non-breaking space
$dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']); $dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']);
} else { } else {
@ -18817,102 +18817,124 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
break; break;
} }
case 'img': { case 'img': {
if (!empty($tag['attribute']['src'])) { if (empty($tag['attribute']['src'])) {
if ($tag['attribute']['src'][0] === '@') { break;
// data stream }
$tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1)); $imgsrc = $tag['attribute']['src'];
$type = ''; if ($imgsrc[0] === '@') {
} else { // data stream
// get image type $imgsrc = '@'.base64_decode(substr($imgsrc, 1));
$type = TCPDF_IMAGES::getImageFileType($tag['attribute']['src']); $type = '';
} } else {
if (!isset($tag['width'])) { if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
$tag['width'] = 0; // fix image path
} $findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
if (!isset($tag['height'])) { if (($findroot === false) OR ($findroot > 1)) {
$tag['height'] = 0; if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
} $imgsrc = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$imgsrc;
//if (!isset($tag['attribute']['align'])) { } else {
// the only alignment supported is "bottom" $imgsrc = $_SERVER['DOCUMENT_ROOT'].$imgsrc;
// further development is required for other modes.
$tag['attribute']['align'] = 'bottom';
//}
switch($tag['attribute']['align']) {
case 'top': {
$align = 'T';
break;
}
case 'middle': {
$align = 'M';
break;
}
case 'bottom': {
$align = 'B';
break;
}
default: {
$align = 'B';
break;
}
}
$prevy = $this->y;
$xpos = $this->x;
$imglink = '';
if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) {
$imglink = $this->HREF['url'];
if ($imglink[0] == '#') {
// convert url to internal link
$lnkdata = explode(',', $imglink);
if (isset($lnkdata[0])) {
$page = intval(substr($lnkdata[0], 1));
if (empty($page) OR ($page <= 0)) {
$page = $this->page;
}
if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
$lnky = floatval($lnkdata[1]);
} else {
$lnky = 0;
}
$imglink = $this->AddLink();
$this->SetLink($imglink, $lnky, $page);
} }
} }
} $imgsrc = urldecode($imgsrc);
$border = 0; $testscrtype = @parse_url($imgsrc);
if (isset($tag['border']) AND !empty($tag['border'])) { if (empty($testscrtype['query'])) {
// currently only support 1 (frame) or a combination of 'LTRB' // convert URL to server path
$border = $tag['border']; $imgsrc = str_replace(K_PATH_URL, K_PATH_MAIN, $imgsrc);
} } elseif (preg_match('|^https?://|', $imgsrc) !== 1) {
$iw = ''; // convert URL to server path
if (isset($tag['width'])) { $imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
$iw = $this->getHTMLUnitToUnits($tag['width'], ($tag['fontsize'] / $this->k), 'px', false);
}
$ih = '';
if (isset($tag['height'])) {
$ih = $this->getHTMLUnitToUnits($tag['height'], ($tag['fontsize'] / $this->k), 'px', false);
}
if (($type == 'eps') OR ($type == 'ai')) {
$this->ImageEps($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, $imglink, true, $align, '', $border, true);
} elseif ($type == 'svg') {
$this->ImageSVG($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, $imglink, $align, '', $border, true);
} else {
$this->Image($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, '', $imglink, $align, false, 300, '', false, false, $border, false, false, true);
}
switch($align) {
case 'T': {
$this->y = $prevy;
break;
} }
case 'M': { }
$this->y = (($this->img_rb_y + $prevy - ($this->getCellHeight($tag['fontsize'] / $this->k))) / 2); // get image type
break; $type = TCPDF_IMAGES::getImageFileType($imgsrc);
} }
case 'B': { if (!isset($tag['width'])) {
$this->y = $this->img_rb_y - ($this->getCellHeight($tag['fontsize'] / $this->k) - ($this->getFontDescent($tag['fontname'], $tag['fontstyle'], $tag['fontsize']) * $this->cell_height_ratio)); $tag['width'] = 0;
break; }
if (!isset($tag['height'])) {
$tag['height'] = 0;
}
//if (!isset($tag['attribute']['align'])) {
// the only alignment supported is "bottom"
// further development is required for other modes.
$tag['attribute']['align'] = 'bottom';
//}
switch($tag['attribute']['align']) {
case 'top': {
$align = 'T';
break;
}
case 'middle': {
$align = 'M';
break;
}
case 'bottom': {
$align = 'B';
break;
}
default: {
$align = 'B';
break;
}
}
$prevy = $this->y;
$xpos = $this->x;
$imglink = '';
if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) {
$imglink = $this->HREF['url'];
if ($imglink[0] == '#') {
// convert url to internal link
$lnkdata = explode(',', $imglink);
if (isset($lnkdata[0])) {
$page = intval(substr($lnkdata[0], 1));
if (empty($page) OR ($page <= 0)) {
$page = $this->page;
}
if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
$lnky = floatval($lnkdata[1]);
} else {
$lnky = 0;
}
$imglink = $this->AddLink();
$this->SetLink($imglink, $lnky, $page);
} }
} }
} }
$border = 0;
if (isset($tag['border']) AND !empty($tag['border'])) {
// currently only support 1 (frame) or a combination of 'LTRB'
$border = $tag['border'];
}
$iw = '';
if (isset($tag['width'])) {
$iw = $this->getHTMLUnitToUnits($tag['width'], ($tag['fontsize'] / $this->k), 'px', false);
}
$ih = '';
if (isset($tag['height'])) {
$ih = $this->getHTMLUnitToUnits($tag['height'], ($tag['fontsize'] / $this->k), 'px', false);
}
if (($type == 'eps') OR ($type == 'ai')) {
$this->ImageEps($imgsrc, $xpos, $this->y, $iw, $ih, $imglink, true, $align, '', $border, true);
} elseif ($type == 'svg') {
$this->ImageSVG($imgsrc, $xpos, $this->y, $iw, $ih, $imglink, $align, '', $border, true);
} else {
$this->Image($imgsrc, $xpos, $this->y, $iw, $ih, '', $imglink, $align, false, 300, '', false, false, $border, false, false, true);
}
switch($align) {
case 'T': {
$this->y = $prevy;
break;
}
case 'M': {
$this->y = (($this->img_rb_y + $prevy - ($this->getCellHeight($tag['fontsize'] / $this->k))) / 2);
break;
}
case 'B': {
$this->y = $this->img_rb_y - ($this->getCellHeight($tag['fontsize'] / $this->k) - ($this->getFontDescent($tag['fontname'], $tag['fontstyle'], $tag['fontsize']) * $this->cell_height_ratio));
break;
}
}
break; break;
} }
case 'dl': { case 'dl': {
@ -24206,9 +24228,12 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
$img = urldecode($img); $img = urldecode($img);
$testscrtype = @parse_url($img); $testscrtype = @parse_url($img);
if (!isset($testscrtype['query']) OR empty($testscrtype['query'])) { if (empty($testscrtype['query'])) {
// convert URL to server path // convert URL to server path
$img = str_replace(K_PATH_URL, K_PATH_MAIN, $img); $img = str_replace(K_PATH_URL, K_PATH_MAIN, $img);
} elseif (preg_match('|^https?://|', $img) !== 1) {
// convert server path to URL
$img = str_replace(K_PATH_MAIN, K_PATH_URL, $img);
} }
} }
// get image type // get image type