32
1
mirror of https://github.com/vdm-io/tcpdf.git synced 2024-11-22 12:55:10 +00:00

6.0.031 (2013-09-18)

- Bug #836 "Optional EOL marker before endstream" was fixed.
- Some additional controls were added to avoid "division by zero" error with badly formatted input.
This commit is contained in:
nicolaasuni 2013-09-18 19:42:19 +01:00
parent a048082831
commit 0c26f23abf
6 changed files with 67 additions and 20 deletions

View File

@ -1,3 +1,7 @@
6.0.031 (2013-09-18)
- Bug #836 "Optional EOL marker before endstream" was fixed.
- Some additional controls were added to avoid "division by zero" error with badly formatted input.
6.0.030 (2013-09-17) 6.0.030 (2013-09-17)
- Bug #835 "PDF417 and Cyrilic simbols" was fixed. - Bug #835 "PDF417 and Cyrilic simbols" was fixed.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 6.0.030 Version: 6.0.031
Release date: 2013-09-17 Release date: 2013-09-18
Author: Nicola Asuni Author: Nicola Asuni
Copyright (c) 2002-2013: Copyright (c) 2002-2013:

View File

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

View File

@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version. * Current TCPDF version.
* @private static * @private static
*/ */
private static $tcpdf_version = '6.0.030'; private static $tcpdf_version = '6.0.031';
/** /**
* String alias for total number of pages. * String alias for total number of pages.

View File

@ -1,7 +1,7 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 6.0.030 // Version : 6.0.031
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2013-09-15 // Last Update : 2013-09-15
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
@ -139,7 +139,7 @@
* Tools to encode your unicode fonts are on fonts/utils directory.</p> * Tools to encode your unicode fonts are on fonts/utils directory.</p>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 6.0.030 * @version 6.0.031
*/ */
// TCPDF configuration // 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> * 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 * @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions. * @brief PHP class for generating PDF documents without requiring external extensions.
* @version 6.0.030 * @version 6.0.031
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -5381,7 +5381,7 @@ class TCPDF {
// get string width without spaces // get string width without spaces
$width = $this->GetStringWidth(str_replace(' ', '', $txt)); $width = $this->GetStringWidth(str_replace(' ', '', $txt));
// calculate average space width // calculate average space width
$spacewidth = -1000 * ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns?$ns:1) / $this->FontSize; $spacewidth = -1000 * ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns?$ns:1) / ($this->FontSize?$this->FontSize:1);
if ($this->font_stretching != 100) { if ($this->font_stretching != 100) {
// word spacing is affected by stretching // word spacing is affected by stretching
$spacewidth /= ($this->font_stretching / 100); $spacewidth /= ($this->font_stretching / 100);
@ -6698,10 +6698,16 @@ class TCPDF {
if ($w <= 0) { if ($w <= 0) {
// set maximum width // set maximum width
$w = ($this->w - $this->lMargin - $this->rMargin); $w = ($this->w - $this->lMargin - $this->rMargin);
if ($w <= 0) {
$w = 1;
}
} }
if ($h <= 0) { if ($h <= 0) {
// set maximum height // set maximum height
$h = ($this->PageBreakTrigger - $this->tMargin); $h = ($this->PageBreakTrigger - $this->tMargin);
if ($h <= 0) {
$h = 1;
}
} }
// resize the block to be vertically contained on a single page or single column // resize the block to be vertically contained on a single page or single column
if ($fitonpage OR $this->AutoPageBreak) { if ($fitonpage OR $this->AutoPageBreak) {
@ -13489,7 +13495,12 @@ class TCPDF {
// calculate aproximatively the ratio between widths of aliases and replacements. // calculate aproximatively the ratio between widths of aliases and replacements.
$ref = '{'.TCPDF_STATIC::$alias_right_shift.'}{'.TCPDF_STATIC::$alias_tot_pages.'}{'.TCPDF_STATIC::$alias_num_page.'}'; $ref = '{'.TCPDF_STATIC::$alias_right_shift.'}{'.TCPDF_STATIC::$alias_tot_pages.'}{'.TCPDF_STATIC::$alias_num_page.'}';
$rep = str_repeat(' ', $this->GetNumChars($ref)); $rep = str_repeat(' ', $this->GetNumChars($ref));
$wdiff = max(1, ($this->GetStringWidth($ref) / $this->GetStringWidth($rep))); $wrep = $this->GetStringWidth($rep);
if ($wrep > 0) {
$wdiff = max(1, ($this->GetStringWidth($ref) / $wrep));
} else {
$wdiff = 1;
}
$sdiff = sprintf('%F', $wdiff); $sdiff = sprintf('%F', $wdiff);
$alias = TCPDF_STATIC::$alias_right_shift.$sdiff.'}'; $alias = TCPDF_STATIC::$alias_right_shift.$sdiff.'}';
if ($this->isUnicodeFont()) { if ($this->isUnicodeFont()) {
@ -13924,6 +13935,9 @@ class TCPDF {
public function colorRegistrationBar($x, $y, $w, $h, $transition=true, $vertical=false, $colors='A,R,G,B,C,M,Y,K') { public function colorRegistrationBar($x, $y, $w, $h, $transition=true, $vertical=false, $colors='A,R,G,B,C,M,Y,K') {
$bars = explode(',', $colors); $bars = explode(',', $colors);
$numbars = count($bars); // number of bars to print $numbars = count($bars); // number of bars to print
if ($numbars <= 0) {
return;
}
// set bar measures // set bar measures
if ($vertical) { if ($vertical) {
$coords = array(0, 0, 0, 1); $coords = array(0, 0, 0, 1);
@ -15016,9 +15030,12 @@ class TCPDF {
// create new barcode object // create new barcode object
$barcodeobj = new TCPDFBarcode($code, $type); $barcodeobj = new TCPDFBarcode($code, $type);
$arrcode = $barcodeobj->getBarcodeArray(); $arrcode = $barcodeobj->getBarcodeArray();
if (($arrcode === false) OR empty($arrcode) OR ($arrcode['maxw'] == 0)) { if (($arrcode === false) OR empty($arrcode) OR ($arrcode['maxw'] <= 0)) {
$this->Error('Error in 1D barcode string'); $this->Error('Error in 1D barcode string');
} }
if ($arrcode['maxh'] <= 0) {
$arrcode['maxh'] = 1;
}
// set default values // set default values
if (!isset($style['position'])) { if (!isset($style['position'])) {
$style['position'] = ''; $style['position'] = '';
@ -15384,10 +15401,13 @@ class TCPDF {
// number of barcode columns and rows // number of barcode columns and rows
$rows = $arrcode['num_rows']; $rows = $arrcode['num_rows'];
$cols = $arrcode['num_cols']; $cols = $arrcode['num_cols'];
if (($rows <= 0) || ($cols <= 0)){
$this->Error('Error in 2D barcode string');
}
// module width and height // module width and height
$mw = $style['module_width']; $mw = $style['module_width'];
$mh = $style['module_height']; $mh = $style['module_height'];
if (($mw == 0) OR ($mh == 0)) { if (($mw <= 0) OR ($mh <= 0)) {
$this->Error('Error in 2D barcode string'); $this->Error('Error in 2D barcode string');
} }
// get max dimensions // get max dimensions
@ -17437,6 +17457,9 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
// calculate additional space to add to each existing space // calculate additional space to add to each existing space
$spacewidth = ($mdiff / ($ns - $no)) * $this->k; $spacewidth = ($mdiff / ($ns - $no)) * $this->k;
if ($this->FontSize <= 0) {
$this->FontSize = 1;
}
$spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize; $spacewidthu = -1000 * ($mdiff + (($ns + $no) * $one_space_width)) / $ns / $this->FontSize;
if ($this->font_spacing != 0) { if ($this->font_spacing != 0) {
// fixed spacing mode // fixed spacing mode
@ -17732,7 +17755,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$this->newline = true; $this->newline = true;
} }
// table // table
if ($dom[$key]['value'] == 'table') { if (($dom[$key]['value'] == 'table') AND isset($dom[$key]['cols']) AND ($dom[$key]['cols'] > 0)) {
// available page width // available page width
if ($this->rtl) { if ($this->rtl) {
$wtmp = $this->x - $this->lMargin; $wtmp = $this->x - $this->lMargin;
@ -17787,7 +17810,10 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
if (isset($dom[$key]['border']) AND !empty($dom[$key]['border'])) { if (isset($dom[$key]['border']) AND !empty($dom[$key]['border'])) {
$tdborder = $dom[$key]['border']; $tdborder = $dom[$key]['border'];
} }
$colspan = $dom[$key]['attribute']['colspan']; $colspan = intval($dom[$key]['attribute']['colspan']);
if ($colspan <= 0) {
$colspan = 1;
}
$old_cell_padding = $this->cell_padding; $old_cell_padding = $this->cell_padding;
if (isset($dom[($dom[$trid]['parent'])]['attribute']['cellpadding'])) { if (isset($dom[($dom[$trid]['parent'])]['attribute']['cellpadding'])) {
$crclpd = $this->getHTMLUnitToUnits($dom[($dom[$trid]['parent'])]['attribute']['cellpadding'], 1, 'px'); $crclpd = $this->getHTMLUnitToUnits($dom[($dom[$trid]['parent'])]['attribute']['cellpadding'], 1, 'px');
@ -21139,7 +21165,12 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$maxpage = max($maxpage, $outline['p']); $maxpage = max($maxpage, $outline['p']);
} }
$fw = ($tw - $this->GetStringWidth($pagenum.$filler)); $fw = ($tw - $this->GetStringWidth($pagenum.$filler));
$numfills = floor($fw / $this->GetStringWidth($filler)); $wfiller = $this->GetStringWidth($filler);
if ($wfiller > 0) {
$numfills = floor($fw / $wfiller);
} else {
$numfills = 0;
}
if ($numfills > 0) { if ($numfills > 0) {
$rowfill = str_repeat($filler, $numfills); $rowfill = str_repeat($filler, $numfills);
} else { } else {
@ -22087,7 +22118,13 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
// check page for no-write regions and adapt page margins if necessary // check page for no-write regions and adapt page margins if necessary
list($x, $y) = $this->checkPageRegions($h, $x, $y); list($x, $y) = $this->checkPageRegions($h, $x, $y);
$ow = $this->xobjects[$id]['w']; $ow = $this->xobjects[$id]['w'];
if ($ow <= 0) {
$ow = 1;
}
$oh = $this->xobjects[$id]['h']; $oh = $this->xobjects[$id]['h'];
if ($oh <= 0) {
$oh = 1;
}
// calculate template width and height on document // calculate template width and height on document
if (($w <= 0) AND ($h <= 0)) { if (($w <= 0) AND ($h <= 0)) {
$w = $ow; $w = $ow;
@ -22128,8 +22165,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
// print XObject Template + Transformation matrix // print XObject Template + Transformation matrix
$this->StartTransform(); $this->StartTransform();
// translate and scale // translate and scale
$sx = ($w / $this->xobjects[$id]['w']); $sx = ($w / $ow);
$sy = ($h / $this->xobjects[$id]['h']); $sy = ($h / $oh);
$tm = array(); $tm = array();
$tm[0] = $sx; $tm[0] = $sx;
$tm[1] = 0; $tm[1] = 0;
@ -22496,6 +22533,12 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
} }
} }
} }
if ($ow <= 0) {
$ow = 1;
}
if ($oh <= 0) {
$oh = 1;
}
// calculate image width and height on document // calculate image width and height on document
if (($w <= 0) AND ($h <= 0)) { if (($w <= 0) AND ($h <= 0)) {
// convert image size to document unit // convert image size to document unit

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf_parser.php // File name : tcpdf_parser.php
// Version : 1.0.007 // Version : 1.0.008
// Begin : 2011-05-23 // Begin : 2011-05-23
// Last Update : 2013-09-15 // Last Update : 2013-09-18
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3 // License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -37,7 +37,7 @@
* This is a PHP class for parsing PDF documents.<br> * This is a PHP class for parsing PDF documents.<br>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 1.0.007 * @version 1.0.008
*/ */
// include class for decoding filters // include class for decoding filters
@ -605,7 +605,7 @@ class TCPDF_PARSER {
$offset += 6; $offset += 6;
if (preg_match('/^([\r]?[\n])/isU', substr($this->pdfdata, $offset), $matches) == 1) { if (preg_match('/^([\r]?[\n])/isU', substr($this->pdfdata, $offset), $matches) == 1) {
$offset += strlen($matches[0]); $offset += strlen($matches[0]);
if (preg_match('/([\r]?[\n])(endstream)/isU', substr($this->pdfdata, $offset), $matches, PREG_OFFSET_CAPTURE) == 1) { if (preg_match('/([\r]?[\n])?(endstream)[\x09\x0a\x0c\x0d\x20]/isU', substr($this->pdfdata, $offset), $matches, PREG_OFFSET_CAPTURE) == 1) {
$objval = substr($this->pdfdata, $offset, $matches[0][1]); $objval = substr($this->pdfdata, $offset, $matches[0][1]);
$offset += $matches[2][1]; $offset += $matches[2][1];
} }