diff --git a/libraries/tcpdf/README.TXT b/libraries/tcpdf/README.TXT
index 61ff935428c0..979cf5393a42 100644
--- a/libraries/tcpdf/README.TXT
+++ b/libraries/tcpdf/README.TXT
@@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
-Version: 5.9.199
-Release date: 2012-11-29
+Version: 5.9.202
+Release date: 2012-12-16
Author: Nicola Asuni
Copyright (c) 2002-2012:
diff --git a/libraries/tcpdf/tcpdf.php b/libraries/tcpdf/tcpdf.php
index 0075ec290588..a6d99cd43834 100644
--- a/libraries/tcpdf/tcpdf.php
+++ b/libraries/tcpdf/tcpdf.php
@@ -1,9 +1,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
- * @version 5.9.199
+ * @version 5.9.202
*/
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@@ -151,7 +151,7 @@
* 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 5.9.199
+ * @version 5.9.202
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
@@ -162,7 +162,7 @@ class TCPDF {
* Current TCPDF version.
* @private
*/
- private $tcpdf_version = '5.9.199';
+ private $tcpdf_version = '5.9.202';
// Protected properties
@@ -275,16 +275,28 @@ class TCPDF {
protected $lMargin;
/**
- * Top margin.
+ * Right margin.
* @protected
*/
- protected $tMargin;
+ protected $rMargin;
/**
- * Right margin.
+ * Cell left margin (used by regions).
* @protected
*/
- protected $rMargin;
+ protected $clMargin;
+
+ /**
+ * Cell right margin (used by regions).
+ * @protected
+ */
+ protected $crMargin;
+
+ /**
+ * Top margin.
+ * @protected
+ */
+ protected $tMargin;
/**
* Page break margin.
@@ -1653,6 +1665,12 @@ class TCPDF {
*/
protected $page_regions = array();
+ /**
+ * Boolean value true when page region check is active.
+ * @protected
+ */
+ protected $check_page_regions = true;
+
/**
* Array containing HTML color names and values.
* @protected
@@ -2034,6 +2052,8 @@ public function __construct($orientation='P', $unit='mm', $format='A4', $unicode
// page margins (1 cm)
$margin = 28.35 / $this->k;
$this->SetMargins($margin, $margin);
+ $this->clMargin = $this->lMargin;
+ $this->crMargin = $this->rMargin;
// internal cell padding
$cpadding = $margin / 10;
$this->setCellPaddings($cpadding, 0, $cpadding, 0);
@@ -5304,7 +5324,7 @@ public function AddFont($family, $style='', $fontfile='', $subset='default') {
$cbbox = array();
}
// initialize subsetchars
- $subsetchars = array();
+ $subsetchars = array_fill(0, 255, true);
$this->setFontBuffer($fontkey, array('fontkey' => $fontkey, 'i' => $this->numfonts, 'type' => $type, 'name' => $name, 'desc' => $desc, 'up' => $up, 'ut' => $ut, 'cw' => $cw, 'cbbox' => $cbbox, 'dw' => $dw, 'enc' => $enc, 'cidinfo' => $cidinfo, 'file' => $file, 'ctg' => $ctg, 'subset' => $subset, 'subsetchars' => $subsetchars));
if ($this->inxobj) {
// we are inside an XObject template
@@ -6726,30 +6746,32 @@ public function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=
// apply margins
$oy = $y + $mc_margin['T'];
if ($this->rtl) {
- $ox = $this->w - $x - $mc_margin['R'];
+ $ox = ($this->w - $x - $mc_margin['R']);
} else {
- $ox = $x + $mc_margin['L'];
+ $ox = ($x + $mc_margin['L']);
}
$this->x = $ox;
$this->y = $oy;
// set width
if ($this->empty_string($w) OR ($w <= 0)) {
if ($this->rtl) {
- $w = $this->x - $this->lMargin - $mc_margin['L'];
+ $w = ($this->x - $this->lMargin - $mc_margin['L']);
} else {
- $w = $this->w - $this->x - $this->rMargin - $mc_margin['R'];
+ $w = ($this->w - $this->x - $this->rMargin - $mc_margin['R']);
}
}
// store original margin values
$lMargin = $this->lMargin;
$rMargin = $this->rMargin;
if ($this->rtl) {
- $this->rMargin = $this->w - $this->x;
- $this->lMargin = $this->x - $w;
+ $this->rMargin = ($this->w - $this->x);
+ $this->lMargin = ($this->x - $w);
} else {
- $this->lMargin = $this->x;
- $this->rMargin = $this->w - $this->x - $w;
+ $this->lMargin = ($this->x);
+ $this->rMargin = ($this->w - $this->x - $w);
}
+ $this->clMargin = $this->lMargin;
+ $this->crMargin = $this->rMargin;
if ($autopadding) {
// add top padding
$this->y += $mc_padding['T'];
@@ -6832,6 +6854,9 @@ public function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=
if ($this->num_columns == 0) {
$this->num_columns = 1;
}
+ // disable page regions check
+ $check_page_regions = $this->check_page_regions;
+ $this->check_page_regions = false;
// get border modes
$border_start = $this->getBorderMode($border, $position='start');
$border_end = $this->getBorderMode($border, $position='end');
@@ -6975,6 +7000,8 @@ public function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=
}
}
} // end for each page
+ // restore page regions check
+ $this->check_page_regions = $check_page_regions;
// Get end-of-cell Y position
$currentY = $this->GetY();
// restore previous values
@@ -7009,6 +7036,8 @@ public function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=
$this->setContentMark();
$this->cell_padding = $prev_cell_padding;
$this->cell_margin = $prev_cell_margin;
+ $this->clMargin = $this->lMargin;
+ $this->crMargin = $this->rMargin;
return $nl;
}
@@ -12764,7 +12793,7 @@ protected function _putXMP() {
$xmp .= "\t\t\t".''."\n";
$xmp .= "\t\t\t".''."\n";
$xmp .= "\t\t\t\t".''."\n";
- $xmp .= "\t\t\t\t\t".''.$this->_escapeXML($this->keywords).''."\n";
+ $xmp .= "\t\t\t\t\t".''.$this->_escapeXML($this->keywords).' TCPDF'."\n";
$xmp .= "\t\t\t\t".''."\n";
$xmp .= "\t\t\t".''."\n";
$xmp .= "\t\t".''."\n";
@@ -23827,6 +23856,10 @@ protected function openHTMLTagHandler($dom, $key, $cell) {
$hbz = $this->FontSize * $this->cell_height_ratio;
}
}
+ if (isset($dom[($key - 1)]) AND ($dom[($key - 1)]['value'] == 'table')) {
+ // fix vertical space after table
+ $hbz = 0;
+ }
}
// Opening tag
switch($tag['value']) {
@@ -23835,6 +23868,7 @@ protected function openHTMLTagHandler($dom, $key, $cell) {
$cs = 0;
$dom[$key]['rowspans'] = array();
if (!isset($dom[$key]['attribute']['nested']) OR ($dom[$key]['attribute']['nested'] != 'true')) {
+ $this->htmlvspace = 0;
// set table header
if (!$this->empty_string($dom[$key]['thead'])) {
// set table header
@@ -24585,12 +24619,12 @@ protected function closeHTMLTagHandler($dom, $key, $cell, $maxbottomliney=0) {
// update row-spanned cells
if (isset($dom[($dom[$key]['parent'])]['rowspans'])) {
foreach ($dom[($dom[$key]['parent'])]['rowspans'] as $k => $trwsp) {
- if ($trwsp['trid'] == $trkey) {
- $dom[($dom[$key]['parent'])]['rowspans'][$k]['mrowspan'] -= 1;
- }
- if (isset($prevtrkey) AND ($trwsp['trid'] == $prevtrkey) AND ($trwsp['mrowspan'] >= 0)) {
+ if (isset($prevtrkey) AND ($trwsp['trid'] == $prevtrkey) AND ($trwsp['mrowspan'] > 0)) {
$dom[($dom[$key]['parent'])]['rowspans'][$k]['trid'] = $trkey;
}
+ if ($dom[($dom[$key]['parent'])]['rowspans'][$k]['trid'] == $trkey) {
+ $dom[($dom[$key]['parent'])]['rowspans'][$k]['mrowspan'] -= 1;
+ }
}
}
if (isset($prevtrkey) AND ($dom[$trkey]['startpage'] > $dom[$prevtrkey]['endpage'])) {
@@ -27975,7 +28009,7 @@ protected function checkPageRegions($h, $x, $y) {
if ($y === '') {
$y = $this->y;
}
- if (empty($this->page_regions)) {
+ if (!$this->check_page_regions OR empty($this->page_regions)) {
// no page regions defined
return array($x, $y);
}
@@ -27990,15 +28024,15 @@ protected function checkPageRegions($h, $x, $y) {
}
if ($this->num_columns > 1) {
if ($this->rtl) {
- $this->lMargin = $this->columns[$this->current_column]['x'] - $this->columns[$this->current_column]['w'];
+ $this->lMargin = ($this->columns[$this->current_column]['x'] - $this->columns[$this->current_column]['w']);
} else {
- $this->rMargin = $this->w - $this->columns[$this->current_column]['x'] - $this->columns[$this->current_column]['w'];
+ $this->rMargin = ($this->w - $this->columns[$this->current_column]['x'] - $this->columns[$this->current_column]['w']);
}
} else {
if ($this->rtl) {
- $this->lMargin = $this->original_lMargin;
+ $this->lMargin = max($this->clMargin, $this->original_lMargin);
} else {
- $this->rMargin = $this->original_rMargin;
+ $this->rMargin = max($this->crMargin, $this->original_rMargin);
}
}
// adjust coordinates and page margins
@@ -28017,7 +28051,7 @@ protected function checkPageRegions($h, $x, $y) {
if ($this->lMargin < $new_margin) {
if ($this->rtl) {
// adjust left page margin
- $this->lMargin = $new_margin;
+ $this->lMargin = max(0, $new_margin);
}
if ($x < $new_margin) {
// adjust x position
@@ -28033,7 +28067,7 @@ protected function checkPageRegions($h, $x, $y) {
if (($this->w - $this->rMargin) > $new_margin) {
if (!$this->rtl) {
// adjust right page margin
- $this->rMargin = ($this->w - $new_margin);
+ $this->rMargin = max(0, ($this->w - $new_margin));
}
if ($x > $new_margin) {
// adjust x position