30
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-06-01 05:40:47 +00:00

5.9.196 (2012-11-02)

- Several methods were improved to avoid output when the context is out of page.
- Bug item #755 "remove cached files before unsetting" was fixed.
This commit is contained in:
Nicola Asuni 2012-11-02 19:26:44 +00:00
parent da47743321
commit d8df0369e3
4 changed files with 133 additions and 37 deletions

View File

@ -1,3 +1,7 @@
5.9.196 (2012-11-02)
- Several methods were improved to avoid output when the context is out of page.
- Bug item #755 "remove cached files before unsetting" was fixed.
5.9.195 (2012-10-24)
- Method _putfonts() was improved.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 5.9.195
Release date: 2012-10-24
Version: 5.9.196
Release date: 2012-11-02
Author: Nicola Asuni
Copyright (c) 2002-2012:

View File

@ -1,6 +1,6 @@
{
"name": "tecnick.com/tcpdf",
"version": "5.9.195",
"version": "5.9.196",
"homepage": "http://www.tcpdf.org/",
"type": "library",
"description": "TCPDF is a PHP class for generating PDF documents.",

144
tcpdf.php
View File

@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 5.9.195
// Version : 5.9.196
// Begin : 2002-08-03
// Last Update : 2012-10-24
// Last Update : 2012-11-02
// Author : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
// -------------------------------------------------------------------
@ -139,7 +139,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 5.9.195
* @version 5.9.196
*/
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@ -151,7 +151,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.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 5.9.195
* @version 5.9.196
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
@ -162,7 +162,7 @@ class TCPDF {
* Current TCPDF version.
* @private
*/
private $tcpdf_version = '5.9.195';
private $tcpdf_version = '5.9.196';
// Protected properties
@ -4405,7 +4405,7 @@ class TCPDF {
* @since 4.0.012 (2008-07-24)
*/
protected function setHeader() {
if (!$this->print_header) {
if (!$this->print_header AND ($this->state != 2)) {
return;
}
$this->InHeader = true;
@ -4445,7 +4445,9 @@ class TCPDF {
* @since 4.0.012 (2008-07-24)
*/
protected function setFooter() {
//Page footer
if ($this->state != 2) {
return;
}
$this->InFooter = true;
// save current graphic settings
$gvars = $this->getGraphicVars();
@ -4647,7 +4649,7 @@ class TCPDF {
}
}
$this->ColorFlag = ($this->FillColor != $this->TextColor);
if ($this->page > 0) {
if ($this->state == 2) {
$this->_out($pdfcolor);
}
if ($this->inxobj) {
@ -4847,7 +4849,7 @@ class TCPDF {
}
}
$this->ColorFlag = ($this->FillColor != $this->TextColor);
if (($type != 'text') AND ($this->page > 0)) {
if (($type != 'text') AND ($this->state == 2)) {
if (!$ret) {
$this->_out($pdfcolor);
}
@ -5412,7 +5414,7 @@ class TCPDF {
}
$this->FontAscent = ($font_ascent / $this->k);
$this->FontDescent = ($font_descent / $this->k);
if ($out AND ($this->page > 0) AND (isset($this->CurrentFont['i']))) {
if ($out AND ($this->page > 0) AND (isset($this->CurrentFont['i'])) AND ($this->state == 2)) {
$this->_out(sprintf('BT /F%d %F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
}
@ -5950,7 +5952,9 @@ class TCPDF {
if ($this->txtshadow['opacity'] != $alpha['CA']) {
$this->setAlpha($this->txtshadow['opacity'], $this->txtshadow['blend_mode']);
}
if ($this->state == 2) {
$this->_out($this->getCellCode($w, $h, $txt, $border, $ln, $align, $fill, $link, $stretch, true, $calign, $valign));
}
//restore data
$this->x = $x;
$this->y = $y;
@ -5961,7 +5965,9 @@ class TCPDF {
$this->setAlpha($alpha['CA'], $alpha['BM'], $alpha['ca'], $alpha['AIS']);
}
}
if ($this->state == 2) {
$this->_out($this->getCellCode($w, $h, $txt, $border, $ln, $align, $fill, $link, $stretch, true, $calign, $valign));
}
$this->cell_padding = $prev_cell_padding;
$this->cell_margin = $prev_cell_margin;
}
@ -7878,6 +7884,9 @@ class TCPDF {
* @since 1.1
*/
public function Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false, $alt=false, $altimgs=array()) {
if ($this->state != 2) {
return;
}
if ($x === '') {
$x = $this->x;
}
@ -9126,7 +9135,7 @@ class TCPDF {
}
/**
* Unset all class variables except the following critical variables: internal_encoding, state, bufferlen, buffer and diskcache.
* Unset all class variables except the following critical variables.
* @param $destroyall (boolean) if true destroys all class variables, otherwise preserves critical variables.
* @param $preserve_objcopy (boolean) if true preserves the objcopy variable
* @public
@ -9137,6 +9146,15 @@ class TCPDF {
// remove buffer file from cache
unlink($this->buffer);
}
if ($destroyall AND isset($this->cached_files) AND !empty($this->cached_files)) {
// remove cached files
foreach ($this->cached_files as $cachefile) {
if (is_file($cachefile)) {
unlink($cachefile);
}
}
unset($this->cached_files);
}
foreach (array_keys(get_object_vars($this)) as $val) {
if ($destroyall OR (
($val != 'internal_encoding')
@ -9155,15 +9173,6 @@ class TCPDF {
}
}
}
if (isset($this->cached_files) AND !empty($this->cached_files)) {
// remove cached files
foreach ($this->cached_files as $cachefile) {
if (is_file($cachefile)) {
unlink($cachefile);
}
}
unset($this->cached_files);
}
}
/**
@ -13600,9 +13609,11 @@ class TCPDF {
// update footer position
$this->footerpos[$this->page] += strlen($s."\n");
} else {
// set page data
$this->setPageBuffer($this->page, $s."\n", true);
}
} else {
} elseif ($this->state > 0) {
// set general data
$this->setBuffer($s."\n");
}
}
@ -14906,6 +14917,9 @@ class TCPDF {
* @see StartTransform(), StopTransform()
*/
public function StartTransform() {
if ($this->state != 2) {
return;
}
$this->_out('q');
if ($this->inxobj) {
// we are inside an XObject template
@ -14926,6 +14940,9 @@ class TCPDF {
* @see StartTransform(), StopTransform()
*/
public function StopTransform() {
if ($this->state != 2) {
return;
}
$this->_out('Q');
if (isset($this->transfmatrix[$this->transfmatrix_key])) {
array_pop($this->transfmatrix[$this->transfmatrix_key]);
@ -15202,6 +15219,9 @@ class TCPDF {
* @see StartTransform(), StopTransform()
*/
protected function Transform($tm) {
if ($this->state != 2) {
return;
}
$this->_out(sprintf('%F %F %F %F %F %F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5]));
// add tranformation matrix
$this->transfmatrix[$this->transfmatrix_key][] = array('a' => $tm[0], 'b' => $tm[1], 'c' => $tm[2], 'd' => $tm[3], 'e' => $tm[4], 'f' => $tm[5]);
@ -15234,7 +15254,7 @@ class TCPDF {
//Set line width
$this->LineWidth = $width;
$this->linestyleWidth = sprintf('%F w', ($width * $this->k));
if ($this->page > 0) {
if ($this->state == 2) {
$this->_out($this->linestyleWidth);
}
}
@ -15322,7 +15342,7 @@ class TCPDF {
if (isset($style['color'])) {
$s .= $this->SetDrawColorArray($style['color'], true).' ';
}
if (!$ret) {
if (!$ret AND ($this->state == 2)) {
$this->_out($s);
}
return $s;
@ -15336,8 +15356,10 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
protected function _outPoint($x, $y) {
if ($this->state == 2) {
$this->_out(sprintf('%F %F m', ($x * $this->k), (($this->h - $y) * $this->k)));
}
}
/**
* Append a straight line segment from the current point to the point (x, y).
@ -15348,8 +15370,10 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
protected function _outLine($x, $y) {
if ($this->state == 2) {
$this->_out(sprintf('%F %F l', ($x * $this->k), (($this->h - $y) * $this->k)));
}
}
/**
* Append a rectangle to the current path as a complete subpath, with lower-left corner (x, y) and dimensions widthand height in user space.
@ -15362,8 +15386,10 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
protected function _outRect($x, $y, $w, $h, $op) {
if ($this->state == 2) {
$this->_out(sprintf('%F %F %F %F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op));
}
}
/**
* Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as the Bézier control points.
@ -15378,8 +15404,10 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
protected function _outCurve($x1, $y1, $x2, $y2, $x3, $y3) {
if ($this->state == 2) {
$this->_out(sprintf('%F %F %F %F %F %F c', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k, $x3 * $this->k, ($this->h - $y3) * $this->k));
}
}
/**
* Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using the current point and (x2, y2) as the Bézier control points.
@ -15392,8 +15420,10 @@ class TCPDF {
* @since 4.9.019 (2010-04-26)
*/
protected function _outCurveV($x2, $y2, $x3, $y3) {
if ($this->state == 2) {
$this->_out(sprintf('%F %F %F %F v', $x2 * $this->k, ($this->h - $y2) * $this->k, $x3 * $this->k, ($this->h - $y3) * $this->k));
}
}
/**
* Append a cubic Bézier curve to the current path. The curve shall extend from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the Bézier control points.
@ -15406,8 +15436,10 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
protected function _outCurveY($x1, $y1, $x3, $y3) {
if ($this->state == 2) {
$this->_out(sprintf('%F %F %F %F y', $x1 * $this->k, ($this->h - $y1) * $this->k, $x3 * $this->k, ($this->h - $y3) * $this->k));
}
}
/**
* Draws a line between two points.
@ -15421,6 +15453,9 @@ class TCPDF {
* @see SetLineWidth(), SetDrawColor(), SetLineStyle()
*/
public function Line($x1, $y1, $x2, $y2, $style=array()) {
if ($this->state != 2) {
return;
}
if (is_array($style)) {
$this->SetLineStyle($style);
}
@ -15448,6 +15483,9 @@ class TCPDF {
* @see SetLineStyle()
*/
public function Rect($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array()) {
if ($this->state != 2) {
return;
}
if (!(false === strpos($style, 'F')) AND !empty($fill_color)) {
$this->SetFillColorArray($fill_color);
}
@ -15503,6 +15541,9 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
public function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style='', $line_style=array(), $fill_color=array()) {
if ($this->state != 2) {
return;
}
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
$this->SetFillColorArray($fill_color);
}
@ -15530,6 +15571,9 @@ class TCPDF {
* @since 3.0008 (2008-05-12)
*/
public function Polycurve($x0, $y0, $segments, $style='', $line_style=array(), $fill_color=array()) {
if ($this->state != 2) {
return;
}
if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
$this->SetFillColorArray($fill_color);
}
@ -15567,6 +15611,9 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
public function Ellipse($x0, $y0, $rx, $ry='', $angle=0, $astart=0, $afinish=360, $style='', $line_style=array(), $fill_color=array(), $nc=2) {
if ($this->state != 2) {
return;
}
if ($this->empty_string($ry) OR ($ry == 0)) {
$ry = $rx;
}
@ -15770,6 +15817,9 @@ class TCPDF {
* @since 2.1.000 (2008-01-08)
*/
public function Polygon($p, $style='', $line_style=array(), $fill_color=array(), $closed=true) {
if ($this->state != 2) {
return;
}
$nc = count($p); // number of coordinates
$np = $nc / 2; // number of points
if ($closed) {
@ -15977,6 +16027,9 @@ class TCPDF {
* @since 4.9.019 (2010-04-22)
*/
public function RoundedRectXY($x, $y, $w, $h, $rx, $ry, $round_corner='1111', $style='', $border_style=array(), $fill_color=array()) {
if ($this->state != 2) {
return;
}
if (($round_corner == '0000') OR (($rx == $ry) AND ($rx == 0))) {
// Not rounded
$this->Rect($x, $y, $w, $h, $style, $border_style, $fill_color);
@ -18570,6 +18623,9 @@ class TCPDF {
* @since 5.9.102 (2011-07-13)
*/
public function startLayer($name='', $print=true, $view=true) {
if ($this->state != 2) {
return;
}
$layer = sprintf('LYR%03d', (count($this->pdflayers) + 1));
if (empty($name)) {
$name = $layer;
@ -18587,6 +18643,9 @@ class TCPDF {
* @since 5.9.102 (2011-07-13)
*/
public function endLayer() {
if ($this->state != 2) {
return;
}
if ($this->openMarkedContent) {
// close existing open marked-content layer
$this->_out('EMC');
@ -18603,6 +18662,9 @@ class TCPDF {
* @since 3.0.000 (2008-03-27)
*/
public function setVisibility($v) {
if ($this->state != 2) {
return;
}
$this->endLayer();
switch($v) {
case 'print': {
@ -18664,7 +18726,7 @@ class TCPDF {
* @since 3.0.000 (2008-03-27)
*/
protected function setExtGState($gs) {
if ($this->pdfa_mode) {
if ($this->pdfa_mode OR ($this->state != 2)) {
// transparency is not allowed in PDF/A mode
return;
}
@ -18706,6 +18768,9 @@ class TCPDF {
* @since 5.9.152 (2012-03-23)
*/
public function setOverprint($stroking=true, $nonstroking='', $mode=0) {
if ($this->state != 2) {
return;
}
$stroking = $stroking ? true : false;
if ($this->empty_string($nonstroking)) {
// default value if not set
@ -19102,7 +19167,7 @@ class TCPDF {
* @public
*/
public function CoonsPatchMesh($x, $y, $w, $h, $col1=array(), $col2=array(), $col3=array(), $col4=array(), $coords=array(0.00,0.0,0.33,0.00,0.67,0.00,1.00,0.00,1.00,0.33,1.00,0.67,1.00,1.00,0.67,1.00,0.33,1.00,0.00,1.00,0.00,0.67,0.00,0.33), $coords_min=0, $coords_max=1, $antialias=false) {
if ($this->pdfa_mode) {
if ($this->pdfa_mode OR ($this->state != 2)) {
return;
}
$this->Clip($x, $y, $w, $h);
@ -19194,6 +19259,9 @@ class TCPDF {
* @protected
*/
protected function Clip($x, $y, $w, $h) {
if ($this->state != 2) {
return;
}
if ($this->rtl) {
$x = $this->w - $x - $w;
}
@ -19218,7 +19286,7 @@ class TCPDF {
* @public
*/
public function Gradient($type, $coords, $stops, $background=array(), $antialias=false) {
if ($this->pdfa_mode) {
if ($this->pdfa_mode OR ($this->state != 2)) {
return;
}
$n = count($this->gradients) + 1;
@ -19536,6 +19604,9 @@ class TCPDF {
* @public
*/
public function PieSectorXY($xc, $yc, $rx, $ry, $a, $b, $style='FD', $cw=false, $o=0, $nc=2) {
if ($this->state != 2) {
return;
}
if ($this->rtl) {
$xc = ($this->w - $xc);
}
@ -19577,6 +19648,9 @@ class TCPDF {
* @public
*/
public function ImageEps($file, $x='', $y='', $w=0, $h=0, $link='', $useBoundingBox=true, $align='', $palign='', $border=0, $fitonpage=false, $fixoutvals=false) {
if ($this->state != 2) {
return;
}
if ($this->rasterize_vector_images AND ($w > 0) AND ($h > 0)) {
// convert EPS to raster image using GD or ImageMagick libraries
return $this->Image($file, $x, $y, $w, $h, 'EPS', $link, $align, true, 300, $palign, false, false, $border, false, false, $fitonpage);
@ -25436,6 +25510,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @since 4.4.004 (2008-12-10)
*/
protected function putHtmlListBullet($listdepth, $listtype='', $size=10) {
if ($this->state != 2) {
return;
}
$size /= $this->k;
$fill = '';
$bgcolor = $this->bgcolor;
@ -25696,6 +25773,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @since 4.2.010 (2008-11-14)
*/
protected function setGraphicVars($gvars, $extended=false) {
if ($this->state != 2) {
return;
}
$this->FontFamily = $gvars['FontFamily'];
$this->FontStyle = $gvars['FontStyle'];
$this->FontSizePt = $gvars['FontSizePt'];
@ -27645,6 +27725,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @see startTemplate(), endTemplate()
*/
public function printTemplate($id, $x='', $y='', $w=0, $h=0, $align='', $palign='', $fitonpage=false) {
if ($this->state != 2) {
return;
}
if (!isset($this->xobjects[$id])) {
$this->Error('The XObject Template \''.$id.'\' doesn\'t exist!');
}
@ -27989,6 +28072,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @public
*/
public function ImageSVG($file, $x='', $y='', $w=0, $h=0, $link='', $align='', $palign='', $border=0, $fitonpage=false) {
if ($this->state != 2) {
return;
}
if ($this->rasterize_vector_images AND ($w > 0) AND ($h > 0)) {
// 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);
@ -28444,6 +28530,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @protected
*/
protected function setSVGStyles($svgstyle, $prevsvgstyle, $x=0, $y=0, $w=1, $h=1, $clip_function='', $clip_params=array()) {
if ($this->state != 2) {
return;
}
$objstyle = '';
$minlen = (0.01 / $this->k); // minimum acceptable length (3 point)
if (!isset($svgstyle['opacity'])) {
@ -28725,6 +28814,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
* @protected
*/
protected function SVGPath($d, $style='') {
if ($this->state != 2) {
return;
}
// set fill/stroke style
$op = $this->getPathPaintOperator($style, '');
if (empty($op)) {