mirror of
https://github.com/vdm-io/tcpdf.git
synced 2024-05-31 21:30:47 +00:00
6.0.025 (2013-09-04)
- A pregSplit() bug was fixed. - Improved content loading from URLs. - Improved font path loading.
This commit is contained in:
parent
6b842db6c4
commit
a8ec5fe7ef
|
@ -1,3 +1,8 @@
|
||||||
|
6.0.025 (2013-09-04)
|
||||||
|
- A pregSplit() bug was fixed.
|
||||||
|
- Improved content loading from URLs.
|
||||||
|
- Improved font path loading.
|
||||||
|
|
||||||
6.0.024 (2013-09-02)
|
6.0.024 (2013-09-02)
|
||||||
- Bug #826 "addEmptySignatureAppearance issue" was fixed.
|
- Bug #826 "addEmptySignatureAppearance issue" was fixed.
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
Name: TCPDF
|
Name: TCPDF
|
||||||
Version: 6.0.024
|
Version: 6.0.025
|
||||||
Release date: 2013-09-02
|
Release date: 2013-09-04
|
||||||
Author: Nicola Asuni
|
Author: Nicola Asuni
|
||||||
|
|
||||||
Copyright (c) 2002-2013:
|
Copyright (c) 2002-2013:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tecnick.com/tcpdf",
|
"name": "tecnick.com/tcpdf",
|
||||||
"version": "6.0.024",
|
"version": "6.0.025",
|
||||||
"homepage": "http://www.tcpdf.org/",
|
"homepage": "http://www.tcpdf.org/",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "TCPDF is a PHP class for generating PDF documents.",
|
"description": "TCPDF is a PHP class for generating PDF documents.",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
//============================================================+
|
//============================================================+
|
||||||
// File name : tcpdf_fonts.php
|
// File name : tcpdf_fonts.php
|
||||||
// Version : 1.0.008
|
// Version : 1.0.009
|
||||||
// Begin : 2008-01-01
|
// Begin : 2008-01-01
|
||||||
// Last Update : 2013-07-18
|
// Last Update : 2013-09-04
|
||||||
// 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)
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
* @class TCPDF_FONTS
|
* @class TCPDF_FONTS
|
||||||
* Font methods for TCPDF library.
|
* Font methods for TCPDF library.
|
||||||
* @package com.tecnick.tcpdf
|
* @package com.tecnick.tcpdf
|
||||||
* @version 1.0.008
|
* @version 1.0.009
|
||||||
* @author Nicola Asuni - info@tecnick.com
|
* @author Nicola Asuni - info@tecnick.com
|
||||||
*/
|
*/
|
||||||
class TCPDF_FONTS {
|
class TCPDF_FONTS {
|
||||||
|
@ -1684,6 +1684,28 @@ class TCPDF_FONTS {
|
||||||
return defined('K_PATH_FONTS') ? K_PATH_FONTS : '';
|
return defined('K_PATH_FONTS') ? K_PATH_FONTS : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return font full path
|
||||||
|
* @param $file (string) Font file name.
|
||||||
|
* @param $fontdir (string) Font directory (set to false fto search on default directories)
|
||||||
|
* @return string Font full path or empty string
|
||||||
|
* @author Nicola Asuni
|
||||||
|
* @since 6.0.025
|
||||||
|
* @public static
|
||||||
|
*/
|
||||||
|
public static function getFontFullPath($file, $fontdir=false) {
|
||||||
|
$fontfile = '';
|
||||||
|
// search files on various directories
|
||||||
|
if (($fontdir !== false) AND @file_exists($fontdir.$file)) {
|
||||||
|
$fontfile = $fontdir.$file;
|
||||||
|
} elseif (@file_exists(self::_getfontpath().$file)) {
|
||||||
|
$fontfile = self::_getfontpath().$file;
|
||||||
|
} elseif (@file_exists($file)) {
|
||||||
|
$fontfile = $file;
|
||||||
|
}
|
||||||
|
return $fontfile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts UTF-8 characters array to array of Latin1 characters array<br>
|
* Converts UTF-8 characters array to array of Latin1 characters array<br>
|
||||||
* @param $unicode (array) array containing UTF-8 unicode values
|
* @param $unicode (array) array containing UTF-8 unicode values
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
//============================================================+
|
//============================================================+
|
||||||
// File name : tcpdf_static.php
|
// File name : tcpdf_static.php
|
||||||
// Version : 1.0.000
|
// Version : 1.0.001
|
||||||
// Begin : 2002-08-03
|
// Begin : 2002-08-03
|
||||||
// Last Update : 2013-04-01
|
// Last Update : 2013-09-04
|
||||||
// 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)
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
* This is a PHP class that contains static methods for the TCPDF class.<br>
|
* This is a PHP class that contains static methods for the TCPDF class.<br>
|
||||||
* @package com.tecnick.tcpdf
|
* @package com.tecnick.tcpdf
|
||||||
* @author Nicola Asuni
|
* @author Nicola Asuni
|
||||||
* @version 1.0.000
|
* @version 1.0.001
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
* Static methods used by the TCPDF class.
|
* Static methods used by the TCPDF class.
|
||||||
* @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 1.0.000
|
* @version 1.0.001
|
||||||
* @author Nicola Asuni - info@tecnick.com
|
* @author Nicola Asuni - info@tecnick.com
|
||||||
*/
|
*/
|
||||||
class TCPDF_STATIC {
|
class TCPDF_STATIC {
|
||||||
|
@ -55,7 +55,7 @@ class TCPDF_STATIC {
|
||||||
* Current TCPDF version.
|
* Current TCPDF version.
|
||||||
* @private static
|
* @private static
|
||||||
*/
|
*/
|
||||||
private static $tcpdf_version = '6.0.024';
|
private static $tcpdf_version = '6.0.025';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String alias for total number of pages.
|
* String alias for total number of pages.
|
||||||
|
@ -2748,12 +2748,88 @@ class TCPDF_STATIC {
|
||||||
$ret[] = "\n";
|
$ret[] = "\n";
|
||||||
$subject = substr($subject, ($nl + 1));
|
$subject = substr($subject, ($nl + 1));
|
||||||
}
|
}
|
||||||
if (!empty($subject)) {
|
if (strlen($subject) > 0) {
|
||||||
$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
|
$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads entire file into a string.
|
||||||
|
* The file can be also an URL.
|
||||||
|
* @param $file (string) Name of the file or URL to read.
|
||||||
|
* @return The function returns the read data or FALSE on failure.
|
||||||
|
* @author Nicola Asuni
|
||||||
|
* @since 6.0.025
|
||||||
|
* @public static
|
||||||
|
*/
|
||||||
|
public static function fileGetContents($file) {
|
||||||
|
// array of possible alternative paths/URLs
|
||||||
|
$alt = array($file);
|
||||||
|
// replace URL relative path with full real server path
|
||||||
|
if ((strlen($file) > 1)
|
||||||
|
AND ($file[0] == '/')
|
||||||
|
AND ($file[1] != '/')
|
||||||
|
AND !empty($_SERVER['DOCUMENT_ROOT'])
|
||||||
|
AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||||
|
$findroot = strpos($file, $_SERVER['DOCUMENT_ROOT']);
|
||||||
|
if (($findroot === false) OR ($findroot > 1)) {
|
||||||
|
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
||||||
|
$tmp = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$file;
|
||||||
|
} else {
|
||||||
|
$tmp = $_SERVER['DOCUMENT_ROOT'].$file;
|
||||||
|
}
|
||||||
|
$alt[] = htmlspecialchars_decode(urldecode($tmp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// URL mode
|
||||||
|
$url = $file;
|
||||||
|
// check for missing protocol
|
||||||
|
if (preg_match('%^/{2}%', $url)) {
|
||||||
|
if (preg_match('%^([^:]+:)//%i', K_PATH_URL, $match)) {
|
||||||
|
$url = $match[1].str_replace(' ', '%20', $url);
|
||||||
|
$alt[] = $url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$urldata = @parse_url($url);
|
||||||
|
if (!isset($urldata['query']) OR (strlen($urldata['query']) <= 0)) {
|
||||||
|
if (strpos($url, K_PATH_URL) === 0) {
|
||||||
|
// convert URL to full server path
|
||||||
|
$tmp = str_replace(K_PATH_URL, K_PATH_MAIN, $url);
|
||||||
|
$tmp = htmlspecialchars_decode(urldecode($tmp));
|
||||||
|
$alt[] = $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($alt as $f) {
|
||||||
|
$ret = @file_get_contents($f);
|
||||||
|
if (($ret === FALSE)
|
||||||
|
AND !ini_get('allow_url_fopen')
|
||||||
|
AND function_exists('curl_init')
|
||||||
|
AND preg_match('%^(https?|ftp)://%', $f)) {
|
||||||
|
// try to get remote file data using cURL
|
||||||
|
$cs = curl_init(); // curl session
|
||||||
|
curl_setopt($cs, CURLOPT_URL, $file);
|
||||||
|
curl_setopt($cs, CURLOPT_BINARYTRANSFER, true);
|
||||||
|
curl_setopt($cs, CURLOPT_FAILONERROR, true);
|
||||||
|
curl_setopt($cs, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
if ((ini_get('open_basedir') == '') AND (!ini_get('safe_mode'))) {
|
||||||
|
curl_setopt($cs, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
}
|
||||||
|
curl_setopt($cs, CURLOPT_CONNECTTIMEOUT, 5);
|
||||||
|
curl_setopt($cs, CURLOPT_TIMEOUT, 30);
|
||||||
|
curl_setopt($cs, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
curl_setopt($cs, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
|
curl_setopt($cs, CURLOPT_USERAGENT, 'TCPDF');
|
||||||
|
$ret = curl_exec($cs);
|
||||||
|
curl_close($cs);
|
||||||
|
}
|
||||||
|
if ($ret !== FALSE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
} // END OF TCPDF_STATIC CLASS
|
} // END OF TCPDF_STATIC CLASS
|
||||||
|
|
||||||
//============================================================+
|
//============================================================+
|
||||||
|
|
217
tcpdf.php
217
tcpdf.php
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
//============================================================+
|
//============================================================+
|
||||||
// File name : tcpdf.php
|
// File name : tcpdf.php
|
||||||
// Version : 6.0.024
|
// Version : 6.0.025
|
||||||
// Begin : 2002-08-03
|
// Begin : 2002-08-03
|
||||||
// Last Update : 2013-09-02
|
// Last Update : 2013-09-04
|
||||||
// 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)
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -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 6.0.024
|
* @version 6.0.025
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TCPDF configuration
|
// TCPDF configuration
|
||||||
|
@ -163,7 +163,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.<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.0.024
|
* @version 6.0.025
|
||||||
* @author Nicola Asuni - info@tecnick.com
|
* @author Nicola Asuni - info@tecnick.com
|
||||||
*/
|
*/
|
||||||
class TCPDF {
|
class TCPDF {
|
||||||
|
@ -4275,33 +4275,22 @@ class TCPDF {
|
||||||
$fontdir .= '/';
|
$fontdir .= '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$missing_style = false; // true when the font style variation is missing
|
// true when the font style variation is missing
|
||||||
|
$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 (!@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';
|
||||||
// search files on various directories
|
$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
|
||||||
if (($fontdir !== false) AND @file_exists($fontdir.$tmp_fontfile)) {
|
if (TCPDF_STATIC::empty_string($fontfile)) {
|
||||||
$fontfile = $fontdir.$tmp_fontfile;
|
|
||||||
} elseif (@file_exists(TCPDF_FONTS::_getfontpath().$tmp_fontfile)) {
|
|
||||||
$fontfile = TCPDF_FONTS::_getfontpath().$tmp_fontfile;
|
|
||||||
} elseif (@file_exists($tmp_fontfile)) {
|
|
||||||
$fontfile = $tmp_fontfile;
|
|
||||||
} elseif (!TCPDF_STATIC::empty_string($style)) {
|
|
||||||
$missing_style = true;
|
$missing_style = true;
|
||||||
// try to remove the style part
|
// try to remove the style part
|
||||||
$tmp_fontfile = str_replace(' ', '', $family).'.php';
|
$tmp_fontfile = str_replace(' ', '', $family).'.php';
|
||||||
if (($fontdir !== false) AND @file_exists($fontdir.$tmp_fontfile)) {
|
$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
|
||||||
$fontfile = $fontdir.$tmp_fontfile;
|
|
||||||
} elseif (@file_exists(TCPDF_FONTS::_getfontpath().$tmp_fontfile)) {
|
|
||||||
$fontfile = TCPDF_FONTS::_getfontpath().$tmp_fontfile;
|
|
||||||
} else {
|
|
||||||
$fontfile = $tmp_fontfile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// include font file
|
// include font file
|
||||||
if (@file_exists($fontfile)) {
|
if (!TCPDF_STATIC::empty_string($fontfile) AND (@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.'');
|
||||||
|
@ -4859,27 +4848,31 @@ class TCPDF {
|
||||||
}
|
}
|
||||||
reset($this->embeddedfiles);
|
reset($this->embeddedfiles);
|
||||||
foreach ($this->embeddedfiles as $filename => $filedata) {
|
foreach ($this->embeddedfiles as $filename => $filedata) {
|
||||||
// update name tree
|
$data = TCPDF_STATIC::fileGetContents($filedata['file']);
|
||||||
$this->efnames[$filename] = $filedata['f'].' 0 R';
|
if ($data !== FALSE) {
|
||||||
// embedded file specification object
|
$rawsize = strlen($data);
|
||||||
$out = $this->_getobj($filedata['f'])."\n";
|
if ($rawsize > 0) {
|
||||||
$out .= '<</Type /Filespec /F '.$this->_datastring($filename, $filedata['f']).' /EF <</F '.$filedata['n'].' 0 R>> >>';
|
// update name tree
|
||||||
$out .= "\n".'endobj';
|
$this->efnames[$filename] = $filedata['f'].' 0 R';
|
||||||
$this->_out($out);
|
// embedded file specification object
|
||||||
// embedded file object
|
$out = $this->_getobj($filedata['f'])."\n";
|
||||||
$data = file_get_contents($filedata['file']);
|
$out .= '<</Type /Filespec /F '.$this->_datastring($filename, $filedata['f']).' /EF <</F '.$filedata['n'].' 0 R>> >>';
|
||||||
$filter = '';
|
$out .= "\n".'endobj';
|
||||||
$rawsize = strlen($data);
|
$this->_out($out);
|
||||||
if ($this->compress) {
|
// embedded file object
|
||||||
$data = gzcompress($data);
|
$filter = '';
|
||||||
$filter = ' /Filter /FlateDecode';
|
if ($this->compress) {
|
||||||
|
$data = gzcompress($data);
|
||||||
|
$filter = ' /Filter /FlateDecode';
|
||||||
|
}
|
||||||
|
$stream = $this->_getrawstream($data, $filedata['n']);
|
||||||
|
$out = $this->_getobj($filedata['n'])."\n";
|
||||||
|
$out .= '<< /Type /EmbeddedFile'.$filter.' /Length '.strlen($stream).' /Params <</Size '.$rawsize.'>> >>';
|
||||||
|
$out .= ' stream'."\n".$stream."\n".'endstream';
|
||||||
|
$out .= "\n".'endobj';
|
||||||
|
$this->_out($out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$stream = $this->_getrawstream($data, $filedata['n']);
|
|
||||||
$out = $this->_getobj($filedata['n'])."\n";
|
|
||||||
$out .= '<< /Type /EmbeddedFile'.$filter.' /Length '.strlen($stream).' /Params <</Size '.$rawsize.'>> >>';
|
|
||||||
$out .= ' stream'."\n".$stream."\n".'endstream';
|
|
||||||
$out .= "\n".'endobj';
|
|
||||||
$this->_out($out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6805,6 +6798,7 @@ class TCPDF {
|
||||||
// check page for no-write regions and adapt page margins if necessary
|
// check page for no-write regions and adapt page margins if necessary
|
||||||
list($x, $y) = $this->checkPageRegions($h, $x, $y);
|
list($x, $y) = $this->checkPageRegions($h, $x, $y);
|
||||||
$exurl = ''; // external streams
|
$exurl = ''; // external streams
|
||||||
|
$imsize = FALSE;
|
||||||
// check if we are passing an image as file or string
|
// check if we are passing an image as file or string
|
||||||
if ($file[0] === '@') {
|
if ($file[0] === '@') {
|
||||||
// image from string
|
// image from string
|
||||||
|
@ -6823,30 +6817,9 @@ class TCPDF {
|
||||||
if (@file_exists($file)) {
|
if (@file_exists($file)) {
|
||||||
// get image dimensions
|
// get image dimensions
|
||||||
$imsize = @getimagesize($file);
|
$imsize = @getimagesize($file);
|
||||||
} else {
|
|
||||||
$imsize = FALSE;
|
|
||||||
}
|
}
|
||||||
if ($imsize === FALSE) {
|
if ($imsize === FALSE) {
|
||||||
if (function_exists('curl_init')) {
|
$imgdata = TCPDF_STATIC::fileGetContents($file);
|
||||||
// try to get remote file data using cURL
|
|
||||||
$cs = curl_init(); // curl session
|
|
||||||
curl_setopt($cs, CURLOPT_URL, $file);
|
|
||||||
curl_setopt($cs, CURLOPT_BINARYTRANSFER, true);
|
|
||||||
curl_setopt($cs, CURLOPT_FAILONERROR, true);
|
|
||||||
curl_setopt($cs, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
if ((ini_get('open_basedir') == '') AND (!ini_get('safe_mode'))) {
|
|
||||||
curl_setopt($cs, CURLOPT_FOLLOWLOCATION, true);
|
|
||||||
}
|
|
||||||
curl_setopt($cs, CURLOPT_CONNECTTIMEOUT, 5);
|
|
||||||
curl_setopt($cs, CURLOPT_TIMEOUT, 30);
|
|
||||||
curl_setopt($cs, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($cs, CURLOPT_SSL_VERIFYHOST, false);
|
|
||||||
curl_setopt($cs, CURLOPT_USERAGENT, 'TCPDF');
|
|
||||||
$imgdata = curl_exec($cs);
|
|
||||||
curl_close($cs);
|
|
||||||
} else {
|
|
||||||
$imgdata = @file_get_contents($file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($imgdata) AND ($imgdata !== FALSE)) {
|
if (isset($imgdata) AND ($imgdata !== FALSE)) {
|
||||||
|
@ -7040,37 +7013,39 @@ class TCPDF {
|
||||||
$img = new Imagick();
|
$img = new Imagick();
|
||||||
if ($type == 'SVG') {
|
if ($type == 'SVG') {
|
||||||
// get SVG file content
|
// get SVG file content
|
||||||
$svgimg = file_get_contents($file);
|
$svgimg = TCPDF_STATIC::fileGetContents($file);
|
||||||
// get width and height
|
if ($svgimg !== FALSE) {
|
||||||
$regs = array();
|
// get width and height
|
||||||
if (preg_match('/<svg([^\>]*)>/si', $svgimg, $regs)) {
|
$regs = array();
|
||||||
$svgtag = $regs[1];
|
if (preg_match('/<svg([^\>]*)>/si', $svgimg, $regs)) {
|
||||||
$tmp = array();
|
$svgtag = $regs[1];
|
||||||
if (preg_match('/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
|
$tmp = array();
|
||||||
$ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
|
if (preg_match('/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
|
||||||
$owu = sprintf('%F', ($ow * $dpi / 72)).$this->pdfunit;
|
$ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
|
||||||
$svgtag = preg_replace('/[\s]+width[\s]*=[\s]*"[^"]*"/si', ' width="'.$owu.'"', $svgtag, 1);
|
$owu = sprintf('%F', ($ow * $dpi / 72)).$this->pdfunit;
|
||||||
} else {
|
$svgtag = preg_replace('/[\s]+width[\s]*=[\s]*"[^"]*"/si', ' width="'.$owu.'"', $svgtag, 1);
|
||||||
$ow = $w;
|
} else {
|
||||||
|
$ow = $w;
|
||||||
|
}
|
||||||
|
$tmp = array();
|
||||||
|
if (preg_match('/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
|
||||||
|
$oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
|
||||||
|
$ohu = sprintf('%F', ($oh * $dpi / 72)).$this->pdfunit;
|
||||||
|
$svgtag = preg_replace('/[\s]+height[\s]*=[\s]*"[^"]*"/si', ' height="'.$ohu.'"', $svgtag, 1);
|
||||||
|
} else {
|
||||||
|
$oh = $h;
|
||||||
|
}
|
||||||
|
$tmp = array();
|
||||||
|
if (!preg_match('/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
|
||||||
|
$vbw = ($ow * $this->imgscale * $this->k);
|
||||||
|
$vbh = ($oh * $this->imgscale * $this->k);
|
||||||
|
$vbox = sprintf(' viewBox="0 0 %F %F" ', $vbw, $vbh);
|
||||||
|
$svgtag = $vbox.$svgtag;
|
||||||
|
}
|
||||||
|
$svgimg = preg_replace('/<svg([^\>]*)>/si', '<svg'.$svgtag.'>', $svgimg, 1);
|
||||||
}
|
}
|
||||||
$tmp = array();
|
$img->readImageBlob($svgimg);
|
||||||
if (preg_match('/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
|
|
||||||
$oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
|
|
||||||
$ohu = sprintf('%F', ($oh * $dpi / 72)).$this->pdfunit;
|
|
||||||
$svgtag = preg_replace('/[\s]+height[\s]*=[\s]*"[^"]*"/si', ' height="'.$ohu.'"', $svgtag, 1);
|
|
||||||
} else {
|
|
||||||
$oh = $h;
|
|
||||||
}
|
|
||||||
$tmp = array();
|
|
||||||
if (!preg_match('/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
|
|
||||||
$vbw = ($ow * $this->imgscale * $this->k);
|
|
||||||
$vbh = ($oh * $this->imgscale * $this->k);
|
|
||||||
$vbox = sprintf(' viewBox="0 0 %F %F" ', $vbw, $vbh);
|
|
||||||
$svgtag = $vbox.$svgtag;
|
|
||||||
}
|
|
||||||
$svgimg = preg_replace('/<svg([^\>]*)>/si', '<svg'.$svgtag.'>', $svgimg, 1);
|
|
||||||
}
|
}
|
||||||
$img->readImageBlob($svgimg);
|
|
||||||
} else {
|
} else {
|
||||||
$img->readImage($file);
|
$img->readImage($file);
|
||||||
}
|
}
|
||||||
|
@ -8746,17 +8721,7 @@ class TCPDF {
|
||||||
TCPDF_STATIC::set_mqr(false);
|
TCPDF_STATIC::set_mqr(false);
|
||||||
foreach ($this->FontFiles as $file => $info) {
|
foreach ($this->FontFiles as $file => $info) {
|
||||||
// search and get font file to embedd
|
// search and get font file to embedd
|
||||||
$fontdir = $info['fontdir'];
|
$fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']);
|
||||||
$file = strtolower($file);
|
|
||||||
$fontfile = '';
|
|
||||||
// search files on various directories
|
|
||||||
if (($fontdir !== false) AND @file_exists($fontdir.$file)) {
|
|
||||||
$fontfile = $fontdir.$file;
|
|
||||||
} elseif (@file_exists(TCPDF_FONTS::_getfontpath().$file)) {
|
|
||||||
$fontfile = TCPDF_FONTS::_getfontpath().$file;
|
|
||||||
} elseif (@file_exists($file)) {
|
|
||||||
$fontfile = $file;
|
|
||||||
}
|
|
||||||
if (!TCPDF_STATIC::empty_string($fontfile)) {
|
if (!TCPDF_STATIC::empty_string($fontfile)) {
|
||||||
$font = file_get_contents($fontfile);
|
$font = file_get_contents($fontfile);
|
||||||
$compressed = (substr($file, -2) == '.z');
|
$compressed = (substr($file, -2) == '.z');
|
||||||
|
@ -8974,15 +8939,7 @@ class TCPDF {
|
||||||
// search and get CTG font file to embedd
|
// search and get CTG font file to embedd
|
||||||
$ctgfile = strtolower($font['ctg']);
|
$ctgfile = strtolower($font['ctg']);
|
||||||
// search and get ctg font file to embedd
|
// search and get ctg font file to embedd
|
||||||
$fontfile = '';
|
$fontfile = TCPDF_FONTS::getFontFullPath($ctgfile, $fontdir);
|
||||||
// search files on various directories
|
|
||||||
if (($fontdir !== false) AND @file_exists($fontdir.$ctgfile)) {
|
|
||||||
$fontfile = $fontdir.$ctgfile;
|
|
||||||
} elseif (@file_exists(TCPDF_FONTS::_getfontpath().$ctgfile)) {
|
|
||||||
$fontfile = TCPDF_FONTS::_getfontpath().$ctgfile;
|
|
||||||
} elseif (@file_exists($ctgfile)) {
|
|
||||||
$fontfile = $ctgfile;
|
|
||||||
}
|
|
||||||
if (TCPDF_STATIC::empty_string($fontfile)) {
|
if (TCPDF_STATIC::empty_string($fontfile)) {
|
||||||
$this->Error('Font file not found: '.$ctgfile);
|
$this->Error('Font file not found: '.$ctgfile);
|
||||||
}
|
}
|
||||||
|
@ -14708,9 +14665,9 @@ class TCPDF {
|
||||||
if ($file{0} === '@') { // image from string
|
if ($file{0} === '@') { // image from string
|
||||||
$data = substr($file, 1);
|
$data = substr($file, 1);
|
||||||
} else { // EPS/AI file
|
} else { // EPS/AI file
|
||||||
$data = file_get_contents($file);
|
$data = TCPDF_STATIC::fileGetContents($file);
|
||||||
}
|
}
|
||||||
if ($data === false) {
|
if ($data === FALSE) {
|
||||||
$this->Error('EPS file not found: '.$file);
|
$this->Error('EPS file not found: '.$file);
|
||||||
}
|
}
|
||||||
$regs = array();
|
$regs = array();
|
||||||
|
@ -16122,8 +16079,10 @@ class TCPDF {
|
||||||
$type = array();
|
$type = array();
|
||||||
if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
|
if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
|
||||||
// read CSS data file
|
// read CSS data file
|
||||||
$cssdata = file_get_contents(trim($type[1]));
|
$cssdata = TCPDF_STATIC::fileGetContents(trim($type[1]));
|
||||||
$css = array_merge($css, TCPDF_STATIC::extractCSSproperties($cssdata));
|
if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) {
|
||||||
|
$css = array_merge($css, TCPDF_STATIC::extractCSSproperties($cssdata));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18556,28 +18515,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
|
||||||
$tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1));
|
$tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1));
|
||||||
$type = '';
|
$type = '';
|
||||||
} else {
|
} else {
|
||||||
// check for images without protocol
|
// get image type
|
||||||
if (preg_match('%^/{2}%', $tag['attribute']['src'])) {
|
|
||||||
$tag['attribute']['src'] = 'http:'.$tag['attribute']['src'];
|
|
||||||
}
|
|
||||||
// replace relative path with real server path
|
|
||||||
if (($tag['attribute']['src'][0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
|
||||||
$findroot = strpos($tag['attribute']['src'], $_SERVER['DOCUMENT_ROOT']);
|
|
||||||
if (($findroot === false) OR ($findroot > 1)) {
|
|
||||||
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
|
||||||
$tag['attribute']['src'] = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$tag['attribute']['src'];
|
|
||||||
} else {
|
|
||||||
$tag['attribute']['src'] = $_SERVER['DOCUMENT_ROOT'].$tag['attribute']['src'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$tag['attribute']['src'] = htmlspecialchars_decode(urldecode($tag['attribute']['src']));
|
|
||||||
$type = TCPDF_IMAGES::getImageFileType($tag['attribute']['src']);
|
$type = TCPDF_IMAGES::getImageFileType($tag['attribute']['src']);
|
||||||
$testscrtype = @parse_url($tag['attribute']['src']);
|
|
||||||
if (!isset($testscrtype['query']) OR empty($testscrtype['query'])) {
|
|
||||||
// convert URL to server path
|
|
||||||
$tag['attribute']['src'] = str_replace(K_PATH_URL, K_PATH_MAIN, $tag['attribute']['src']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!isset($tag['width'])) {
|
if (!isset($tag['width'])) {
|
||||||
$tag['width'] = 0;
|
$tag['width'] = 0;
|
||||||
|
@ -22484,9 +22423,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
|
||||||
$svgdata = substr($file, 1);
|
$svgdata = substr($file, 1);
|
||||||
} else { // SVG file
|
} else { // SVG file
|
||||||
$this->svgdir = dirname($file);
|
$this->svgdir = dirname($file);
|
||||||
$svgdata = file_get_contents($file);
|
$svgdata = TCPDF_STATIC::fileGetContents($file);
|
||||||
}
|
}
|
||||||
if ($svgdata === false) {
|
if ($svgdata === FALSE) {
|
||||||
$this->Error('SVG file not found: '.$file);
|
$this->Error('SVG file not found: '.$file);
|
||||||
}
|
}
|
||||||
if ($x === '') {
|
if ($x === '') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user