From acb0db3a6d187aabff73dfc07ad555d672de1d07 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 19 Nov 2013 22:20:54 +0000 Subject: [PATCH] 6.0.047 (2013-11-19) - SVG support was extended to support some nested defs. --- CHANGELOG.TXT | 3 ++ README.TXT | 4 +-- composer.json | 2 +- include/tcpdf_static.php | 2 +- tcpdf.php | 62 +++++++++++++++++++++++++++++++++------- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 17ec959..443fa84 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.047 (2013-11-19) + - SVG support was extended to support some nested defs. + 6.0.046 (2013-11-17) - preg_replace_callback functions were replaced to improve memory performances. diff --git a/README.TXT b/README.TXT index 2f1fac1..b7c49e4 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.046 -Release date: 2013-11-17 +Version: 6.0.047 +Release date: 2013-11-19 Author: Nicola Asuni Copyright (c) 2002-2013: diff --git a/composer.json b/composer.json index b63a528..f5ddb46 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.046", + "version": "6.0.047", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 75879df..55c8b9e 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.046'; + private static $tcpdf_version = '6.0.047'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index c5973ef..a69ca65 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.046 + * @version 6.0.047 */ // 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.046 + * @version 6.0.047 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -23538,10 +23538,19 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: return; } if ($this->svgdefsmode AND !in_array($name, array('clipPath', 'linearGradient', 'radialGradient', 'stop'))) { - if (!isset($attribs['id'])) { - $attribs['id'] = 'DF_'.(count($this->svgdefs) + 1); + if (isset($attribs['id'])) { + $attribs['child_elements'] = array(); + $this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs); + return; + } + if (end($this->svgdefs) !== FALSE) { + $last_svgdefs_id = key($this->svgdefs); + if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) { + $attribs['id'] = 'DF_'.(count($this->svgdefs) + 1); + $this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$attribs['id']] = array('name' => $name, 'attribs' => $attribs); + return; + } } - $this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs); return; } $clipping = false; @@ -23550,7 +23559,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $clipping = true; } // get styling properties - $prev_svgstyle = $this->svgstyles[(count($this->svgstyles) - 1)]; // previous style + $prev_svgstyle = $this->svgstyles[max(0,(count($this->svgstyles) - 1))]; // previous style $svgstyle = $this->svgstyles[0]; // set default style if ($clipping AND !isset($attribs['fill']) AND (!isset($attribs['style']) OR (!preg_match('/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval)))) { // default fill attribute for clipping @@ -24040,7 +24049,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $attribs['y'] += $use['attribs']['y']; } $attribs = array_merge($use['attribs'], $attribs); - $this->startSVGElementHandler($parser, $use['name'], $attribs); + $this->startSVGElementHandler('use-tag', $use['name'], $attribs); + return; } } break; @@ -24049,6 +24059,18 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: break; } } // end of switch + // process child elements + if (!empty($attribs['child_elements'])) { + $child_elements = $attribs['child_elements']; + unset($attribs['child_elements']); + foreach($child_elements as $child_element) { + if (empty($child_element['attribs']['closing_tag'])) { + $this->startSVGElementHandler('child-tag', $child_element['name'], $child_element['attribs']); + } else { + $this->endSVGElementHandler('child-tag', $child_element['name']); + } + } + } } /** @@ -24060,6 +24082,24 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: * @protected */ protected function endSVGElementHandler($parser, $name) { + if ($this->svgdefsmode AND !in_array($name, array('defs', 'clipPath', 'linearGradient', 'radialGradient', 'stop'))) {; + if (end($this->svgdefs) !== FALSE) { + $last_svgdefs_id = key($this->svgdefs); + if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) { + foreach($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'] as $child_element) { + if (isset($child_element['attribs']['id']) AND ($child_element['name'] == $name)) { + $this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$child_element['attribs']['id'].'_CLOSE'] = array('name' => $name, 'attribs' => array('closing_tag' => TRUE)); + return; + } + } + if ($this->svgdefs[$last_svgdefs_id]['name'] == $name) { + $this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$last_svgdefs_id.'_CLOSE'] = array('name' => $name, 'attribs' => array('closing_tag' => TRUE)); + return; + } + } + } + return; + } switch($name) { case 'defs': { $this->svgdefsmode = false; @@ -24122,7 +24162,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $this->textstrokewidth = $textstrokewidth; $this->svgtext = ''; $this->StopTransform(); - array_pop($this->svgstyles); + if (!$this->svgdefsmode) { + array_pop($this->svgstyles); + } break; } default: {