Skip to content

Commit

Permalink
Update TCPDF to 5.9.202
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Dec 20, 2012
1 parent b614b32 commit baa3300
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 32 deletions.
4 changes: 2 additions & 2 deletions libraries/tcpdf/README.TXT
Expand Up @@ -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:
Expand Down
94 changes: 64 additions & 30 deletions libraries/tcpdf/tcpdf.php
@@ -1,9 +1,9 @@
<?php
//============================================================+
// File name : tcpdf.php
// Version : 5.9.199
// Version : 5.9.202
// Begin : 2002-08-03
// Last Update : 2012-11-29
// Last Update : 2012-12-16
// 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
// -------------------------------------------------------------------
Expand Down Expand Up @@ -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.199
* @version 5.9.202
*/

// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
Expand All @@ -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.<br>
* @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 {
Expand All @@ -162,7 +162,7 @@ class TCPDF {
* Current TCPDF version.
* @private
*/
private $tcpdf_version = '5.9.199';
private $tcpdf_version = '5.9.202';

// Protected properties

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -12764,7 +12793,7 @@ protected function _putXMP() {
$xmp .= "\t\t\t".'</dc:description>'."\n";
$xmp .= "\t\t\t".'<dc:subject>'."\n";
$xmp .= "\t\t\t\t".'<rdf:Bag>'."\n";
$xmp .= "\t\t\t\t\t".'<rdf:li>'.$this->_escapeXML($this->keywords).'</rdf:li>'."\n";
$xmp .= "\t\t\t\t\t".'<rdf:li>'.$this->_escapeXML($this->keywords).' TCPDF</rdf:li>'."\n";
$xmp .= "\t\t\t\t".'</rdf:Bag>'."\n";
$xmp .= "\t\t\t".'</dc:subject>'."\n";
$xmp .= "\t\t".'</rdf:Description>'."\n";
Expand Down Expand Up @@ -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']) {
Expand All @@ -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
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit baa3300

Please sign in to comment.