mirror of
https://github.com/vdm-io/tcpdf.git
synced 2025-01-10 23:41:44 +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)
|
||||
- Bug #826 "addEmptySignatureAppearance issue" was fixed.
|
||||
|
||||
|
@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
|
||||
------------------------------------------------------------
|
||||
|
||||
Name: TCPDF
|
||||
Version: 6.0.024
|
||||
Release date: 2013-09-02
|
||||
Version: 6.0.025
|
||||
Release date: 2013-09-04
|
||||
Author: Nicola Asuni
|
||||
|
||||
Copyright (c) 2002-2013:
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tecnick.com/tcpdf",
|
||||
"version": "6.0.024",
|
||||
"version": "6.0.025",
|
||||
"homepage": "http://www.tcpdf.org/",
|
||||
"type": "library",
|
||||
"description": "TCPDF is a PHP class for generating PDF documents.",
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_fonts.php
|
||||
// Version : 1.0.008
|
||||
// Version : 1.0.009
|
||||
// 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
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
@ -42,7 +42,7 @@
|
||||
* @class TCPDF_FONTS
|
||||
* Font methods for TCPDF library.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.008
|
||||
* @version 1.0.009
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_FONTS {
|
||||
@ -1684,6 +1684,28 @@ class TCPDF_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>
|
||||
* @param $unicode (array) array containing UTF-8 unicode values
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_static.php
|
||||
// Version : 1.0.000
|
||||
// Version : 1.0.001
|
||||
// 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
|
||||
// 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>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.000
|
||||
* @version 1.0.001
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@
|
||||
* Static methods used by the TCPDF class.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @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
|
||||
*/
|
||||
class TCPDF_STATIC {
|
||||
@ -55,7 +55,7 @@ class TCPDF_STATIC {
|
||||
* Current TCPDF version.
|
||||
* @private static
|
||||
*/
|
||||
private static $tcpdf_version = '6.0.024';
|
||||
private static $tcpdf_version = '6.0.025';
|
||||
|
||||
/**
|
||||
* String alias for total number of pages.
|
||||
@ -2748,12 +2748,88 @@ class TCPDF_STATIC {
|
||||
$ret[] = "\n";
|
||||
$subject = substr($subject, ($nl + 1));
|
||||
}
|
||||
if (!empty($subject)) {
|
||||
if (strlen($subject) > 0) {
|
||||
$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
|
||||
}
|
||||
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
|
||||
|
||||
//============================================================+
|
||||
|
123
tcpdf.php
123
tcpdf.php
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf.php
|
||||
// Version : 6.0.024
|
||||
// Version : 6.0.025
|
||||
// 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
|
||||
// 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>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 6.0.024
|
||||
* @version 6.0.025
|
||||
*/
|
||||
|
||||
// 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>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @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
|
||||
*/
|
||||
class TCPDF {
|
||||
@ -4275,33 +4275,22 @@ class TCPDF {
|
||||
$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
|
||||
if (TCPDF_STATIC::empty_string($fontfile) OR (!@file_exists($fontfile))) {
|
||||
// build a standard filenames for specified font
|
||||
$tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php';
|
||||
// search files on various directories
|
||||
if (($fontdir !== false) AND @file_exists($fontdir.$tmp_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)) {
|
||||
$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
|
||||
if (TCPDF_STATIC::empty_string($fontfile)) {
|
||||
$missing_style = true;
|
||||
// try to remove the style part
|
||||
$tmp_fontfile = str_replace(' ', '', $family).'.php';
|
||||
if (($fontdir !== false) AND @file_exists($fontdir.$tmp_fontfile)) {
|
||||
$fontfile = $fontdir.$tmp_fontfile;
|
||||
} elseif (@file_exists(TCPDF_FONTS::_getfontpath().$tmp_fontfile)) {
|
||||
$fontfile = TCPDF_FONTS::_getfontpath().$tmp_fontfile;
|
||||
} else {
|
||||
$fontfile = $tmp_fontfile;
|
||||
}
|
||||
$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
|
||||
}
|
||||
}
|
||||
// include font file
|
||||
if (@file_exists($fontfile)) {
|
||||
if (!TCPDF_STATIC::empty_string($fontfile) AND (@file_exists($fontfile))) {
|
||||
include($fontfile);
|
||||
} else {
|
||||
$this->Error('Could not include font definition file: '.$family.'');
|
||||
@ -4859,6 +4848,10 @@ class TCPDF {
|
||||
}
|
||||
reset($this->embeddedfiles);
|
||||
foreach ($this->embeddedfiles as $filename => $filedata) {
|
||||
$data = TCPDF_STATIC::fileGetContents($filedata['file']);
|
||||
if ($data !== FALSE) {
|
||||
$rawsize = strlen($data);
|
||||
if ($rawsize > 0) {
|
||||
// update name tree
|
||||
$this->efnames[$filename] = $filedata['f'].' 0 R';
|
||||
// embedded file specification object
|
||||
@ -4867,9 +4860,7 @@ class TCPDF {
|
||||
$out .= "\n".'endobj';
|
||||
$this->_out($out);
|
||||
// embedded file object
|
||||
$data = file_get_contents($filedata['file']);
|
||||
$filter = '';
|
||||
$rawsize = strlen($data);
|
||||
if ($this->compress) {
|
||||
$data = gzcompress($data);
|
||||
$filter = ' /Filter /FlateDecode';
|
||||
@ -4882,6 +4873,8 @@ class TCPDF {
|
||||
$this->_out($out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a text cell at the specified position.
|
||||
@ -6805,6 +6798,7 @@ class TCPDF {
|
||||
// check page for no-write regions and adapt page margins if necessary
|
||||
list($x, $y) = $this->checkPageRegions($h, $x, $y);
|
||||
$exurl = ''; // external streams
|
||||
$imsize = FALSE;
|
||||
// check if we are passing an image as file or string
|
||||
if ($file[0] === '@') {
|
||||
// image from string
|
||||
@ -6823,30 +6817,9 @@ class TCPDF {
|
||||
if (@file_exists($file)) {
|
||||
// get image dimensions
|
||||
$imsize = @getimagesize($file);
|
||||
} else {
|
||||
$imsize = FALSE;
|
||||
}
|
||||
if ($imsize === FALSE) {
|
||||
if (function_exists('curl_init')) {
|
||||
// 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);
|
||||
}
|
||||
$imgdata = TCPDF_STATIC::fileGetContents($file);
|
||||
}
|
||||
}
|
||||
if (isset($imgdata) AND ($imgdata !== FALSE)) {
|
||||
@ -7040,7 +7013,8 @@ class TCPDF {
|
||||
$img = new Imagick();
|
||||
if ($type == 'SVG') {
|
||||
// get SVG file content
|
||||
$svgimg = file_get_contents($file);
|
||||
$svgimg = TCPDF_STATIC::fileGetContents($file);
|
||||
if ($svgimg !== FALSE) {
|
||||
// get width and height
|
||||
$regs = array();
|
||||
if (preg_match('/<svg([^\>]*)>/si', $svgimg, $regs)) {
|
||||
@ -7071,6 +7045,7 @@ class TCPDF {
|
||||
$svgimg = preg_replace('/<svg([^\>]*)>/si', '<svg'.$svgtag.'>', $svgimg, 1);
|
||||
}
|
||||
$img->readImageBlob($svgimg);
|
||||
}
|
||||
} else {
|
||||
$img->readImage($file);
|
||||
}
|
||||
@ -8746,17 +8721,7 @@ class TCPDF {
|
||||
TCPDF_STATIC::set_mqr(false);
|
||||
foreach ($this->FontFiles as $file => $info) {
|
||||
// search and get font file to embedd
|
||||
$fontdir = $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;
|
||||
}
|
||||
$fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']);
|
||||
if (!TCPDF_STATIC::empty_string($fontfile)) {
|
||||
$font = file_get_contents($fontfile);
|
||||
$compressed = (substr($file, -2) == '.z');
|
||||
@ -8974,15 +8939,7 @@ class TCPDF {
|
||||
// search and get CTG font file to embedd
|
||||
$ctgfile = strtolower($font['ctg']);
|
||||
// search and get ctg font file to embedd
|
||||
$fontfile = '';
|
||||
// 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;
|
||||
}
|
||||
$fontfile = TCPDF_FONTS::getFontFullPath($ctgfile, $fontdir);
|
||||
if (TCPDF_STATIC::empty_string($fontfile)) {
|
||||
$this->Error('Font file not found: '.$ctgfile);
|
||||
}
|
||||
@ -14708,9 +14665,9 @@ class TCPDF {
|
||||
if ($file{0} === '@') { // image from string
|
||||
$data = substr($file, 1);
|
||||
} 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);
|
||||
}
|
||||
$regs = array();
|
||||
@ -16122,13 +16079,15 @@ class TCPDF {
|
||||
$type = array();
|
||||
if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
|
||||
// read CSS data file
|
||||
$cssdata = file_get_contents(trim($type[1]));
|
||||
$cssdata = TCPDF_STATIC::fileGetContents(trim($type[1]));
|
||||
if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) {
|
||||
$css = array_merge($css, TCPDF_STATIC::extractCSSproperties($cssdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// extract style tags
|
||||
$matches = array();
|
||||
if (preg_match_all('/<style([^\>]*)>([^\<]*)<\/style>/isU', $html, $matches) > 0) {
|
||||
@ -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));
|
||||
$type = '';
|
||||
} else {
|
||||
// check for images without protocol
|
||||
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']));
|
||||
// get image type
|
||||
$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'])) {
|
||||
$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);
|
||||
} else { // SVG 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);
|
||||
}
|
||||
if ($x === '') {
|
||||
|
Loading…
Reference in New Issue
Block a user