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

6.0.028 (2013-09-15)

- A debug print_r was removed form tcpdf_parser.php.
- TCPDF_FILTERS now throws an exception in case of error.
- TCPDF_PARSER now throws an exception in case of error unless you define the constant K_TCPDF_PARSER_THROW_EXCEPTION_ERROR to false.
This commit is contained in:
nicolaasuni 2013-09-15 10:29:41 +01:00
parent 88efb72a26
commit 0dd315280d
7 changed files with 58 additions and 44 deletions

View File

@ -1,3 +1,8 @@
6.0.028 (2013-09-15)
- A debug print_r was removed form tcpdf_parser.php.
- TCPDF_FILTERS now throws an exception in case of error.
- TCPDF_PARSER now throws an exception in case of error unless you define the constant K_TCPDF_PARSER_THROW_EXCEPTION_ERROR to false.
6.0.027 (2013-09-14) 6.0.027 (2013-09-14)
- A bug in tcpdf_parser wen parsing hexadecimal strings was fixed. - A bug in tcpdf_parser wen parsing hexadecimal strings was fixed.
- A bug in tcpdf_parser wen looking for statxref was fixed. - A bug in tcpdf_parser wen looking for statxref was fixed.

View File

@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------ ------------------------------------------------------------
Name: TCPDF Name: TCPDF
Version: 6.0.027 Version: 6.0.028
Release date: 2013-09-14 Release date: 2013-09-15
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.027", "version": "6.0.028",
"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

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf_filters.php // File name : tcpdf_filters.php
// Version : 1.0.000 // Version : 1.0.001
// Begin : 2011-05-23 // Begin : 2011-05-23
// Last Update : 2013-03-17 // 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
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -37,7 +37,7 @@
* This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br> * This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @author Nicola Asuni * @author Nicola Asuni
* @version 1.0.000 * @version 1.0.001
*/ */
/** /**
@ -45,7 +45,7 @@
* This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br> * This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br>
* @package com.tecnick.tcpdf * @package com.tecnick.tcpdf
* @brief This is a PHP class for decoding common PDF filters. * @brief This is a PHP class for decoding common PDF filters.
* @version 1.0.000 * @version 1.0.001
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF_FILTERS { class TCPDF_FILTERS {
@ -167,12 +167,12 @@ class TCPDF_FILTERS {
// EOD shall behave as if a 0 (zero) followed the last digit // EOD shall behave as if a 0 (zero) followed the last digit
$data = substr($data, 0, -1).'0'.substr($data, -1); $data = substr($data, 0, -1).'0'.substr($data, -1);
} else { } else {
self::Error('decodeASCIIHex: invalid code'); self::Error('decodeFilterASCIIHexDecode: invalid code');
} }
} }
// check for invalid characters // check for invalid characters
if (preg_match('/[^a-fA-F\d]/', $data) > 0) { if (preg_match('/[^a-fA-F\d]/', $data) > 0) {
self::Error('decodeASCIIHex: invalid code'); self::Error('decodeFilterASCIIHexDecode: invalid code');
} }
// get one byte of binary data for each pair of ASCII hexadecimal digits // get one byte of binary data for each pair of ASCII hexadecimal digits
$decoded = pack('H*', $data); $decoded = pack('H*', $data);
@ -207,7 +207,7 @@ class TCPDF_FILTERS {
$data_length = strlen($data); $data_length = strlen($data);
// check for invalid characters // check for invalid characters
if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) { if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) {
self::Error('decodeASCII85: invalid code'); self::Error('decodeFilterASCII85Decode: invalid code');
} }
// z sequence // z sequence
$zseq = chr(0).chr(0).chr(0).chr(0); $zseq = chr(0).chr(0).chr(0).chr(0);
@ -224,7 +224,7 @@ class TCPDF_FILTERS {
if ($group_pos == 0) { if ($group_pos == 0) {
$decoded .= $zseq; $decoded .= $zseq;
} else { } else {
self::Error('decodeASCII85: invalid code'); self::Error('decodeFilterASCII85Decode: invalid code');
} }
} else { } else {
// the value represented by a group of 5 characters should never be greater than 2^32 - 1 // the value represented by a group of 5 characters should never be greater than 2^32 - 1
@ -256,7 +256,7 @@ class TCPDF_FILTERS {
break; break;
} }
case 1: { case 1: {
self::Error('decodeASCII85: invalid code'); self::Error('decodeFilterASCII85Decode: invalid code');
break; break;
} }
} }
@ -354,9 +354,9 @@ class TCPDF_FILTERS {
*/ */
public static function decodeFilterFlateDecode($data) { public static function decodeFilterFlateDecode($data) {
// intialize string to return // intialize string to return
$decoded = gzuncompress($data); $decoded = @gzuncompress($data);
if ($decoded === false) { if ($decoded === false) {
self::Error('decodeFlate: invalid code'); self::Error('decodeFilterFlateDecode: invalid code');
} }
return $decoded; return $decoded;
} }
@ -398,7 +398,7 @@ class TCPDF_FILTERS {
} }
/** /**
* CCITTFaxDecode (NOT IMPLEMETED) * CCITTFaxDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel). * Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
* @param $data (string) Data to decode. * @param $data (string) Data to decode.
* @return Decoded data string. * @return Decoded data string.
@ -406,11 +406,12 @@ class TCPDF_FILTERS {
* @public static * @public static
*/ */
public static function decodeFilterCCITTFaxDecode($data) { public static function decodeFilterCCITTFaxDecode($data) {
return $data; self::Error('decodeFilterCCITTFaxDecode: this method has not been yet implemented');
//return $data;
} }
/** /**
* JBIG2Decode (NOT IMPLEMETED) * JBIG2Decode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data). * Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
* @param $data (string) Data to decode. * @param $data (string) Data to decode.
* @return Decoded data string. * @return Decoded data string.
@ -418,11 +419,12 @@ class TCPDF_FILTERS {
* @public static * @public static
*/ */
public static function decodeFilterJBIG2Decode($data) { public static function decodeFilterJBIG2Decode($data) {
return $data; self::Error('decodeFilterJBIG2Decode: this method has not been yet implemented');
//return $data;
} }
/** /**
* DCTDecode (NOT IMPLEMETED) * DCTDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data. * Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
* @param $data (string) Data to decode. * @param $data (string) Data to decode.
* @return Decoded data string. * @return Decoded data string.
@ -430,11 +432,12 @@ class TCPDF_FILTERS {
* @public static * @public static
*/ */
public static function decodeFilterDCTDecode($data) { public static function decodeFilterDCTDecode($data) {
return $data; self::Error('decodeFilterDCTDecode: this method has not been yet implemented');
//return $data;
} }
/** /**
* JPXDecode (NOT IMPLEMETED) * JPXDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data. * Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
* @param $data (string) Data to decode. * @param $data (string) Data to decode.
* @return Decoded data string. * @return Decoded data string.
@ -442,11 +445,12 @@ class TCPDF_FILTERS {
* @public static * @public static
*/ */
public static function decodeFilterJPXDecode($data) { public static function decodeFilterJPXDecode($data) {
return $data; self::Error('decodeFilterJPXDecode: this method has not been yet implemented');
//return $data;
} }
/** /**
* Crypt (NOT IMPLEMETED) * Crypt (NOT IMPLEMETED - RETURN AN EXCEPTION)
* Decrypts data encrypted by a security handler, reproducing the data as it was before encryption. * Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
* @param $data (string) Data to decode. * @param $data (string) Data to decode.
* @return Decoded data string. * @return Decoded data string.
@ -454,20 +458,20 @@ class TCPDF_FILTERS {
* @public static * @public static
*/ */
public static function decodeFilterCrypt($data) { public static function decodeFilterCrypt($data) {
return $data; self::Error('decodeFilterCrypt: this method has not been yet implemented');
//return $data;
} }
// --- END FILTERS SECTION ------------------------------------------------- // --- END FILTERS SECTION -------------------------------------------------
/** /**
* This method is automatically called in case of fatal error; it simply outputs the message and halts the execution. * Throw an exception.
* @param $msg (string) The error message * @param $msg (string) The error message
* @since 1.0.000 (2011-05-23) * @since 1.0.000 (2011-05-23)
* @public static * @public static
*/ */
public static function Error($msg) { public static function Error($msg) {
// exit program and print error throw new Exception('TCPDF_PARSER ERROR: '.$msg);
die('<strong>TCPDF_FILTERS ERROR: </strong>'.$msg);
} }
} // END OF TCPDF_FILTERS CLASS } // END OF TCPDF_FILTERS CLASS

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.027'; private static $tcpdf_version = '6.0.028';
/** /**
* String alias for total number of pages. * String alias for total number of pages.

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf.php // File name : tcpdf.php
// Version : 6.0.027 // Version : 6.0.028
// Begin : 2002-08-03 // Begin : 2002-08-03
// Last Update : 2013-09-14 // 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
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -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.027 * @version 6.0.028
*/ */
// 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.027 * @version 6.0.028
* @author Nicola Asuni - info@tecnick.com * @author Nicola Asuni - info@tecnick.com
*/ */
class TCPDF { class TCPDF {
@ -2919,8 +2919,7 @@ class TCPDF {
} }
/** /**
* This method is automatically called in case of fatal error; it simply outputs the message and halts the execution. An inherited class may override it to customize the error handling but should always halt the script, or the resulting document would probably be invalid. * Throw an exception or print an error message and die if the K_TCPDF_PARSER_THROW_EXCEPTION_ERROR constant is set to true.
* 2004-06-11 :: Nicola Asuni : changed bold tag with strong
* @param $msg (string) The error message * @param $msg (string) The error message
* @public * @public
* @since 1.0 * @since 1.0
@ -2928,8 +2927,7 @@ class TCPDF {
public function Error($msg) { public function Error($msg) {
// unset all class variables // unset all class variables
$this->_destroy(true); $this->_destroy(true);
// exit program and print error if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) {
if (!K_TCPDF_THROW_EXCEPTION_ERROR) {
die('<strong>TCPDF ERROR: </strong>'.$msg); die('<strong>TCPDF ERROR: </strong>'.$msg);
} else { } else {
throw new Exception('TCPDF ERROR: '.$msg); throw new Exception('TCPDF ERROR: '.$msg);

View File

@ -1,9 +1,9 @@
<?php <?php
//============================================================+ //============================================================+
// File name : tcpdf_parser.php // File name : tcpdf_parser.php
// Version : 1.0.005 // Version : 1.0.006
// Begin : 2011-05-23 // Begin : 2011-05-23
// Last Update : 2013-09-14 // 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
// 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.005 * @version 1.0.006
*/ */
// include class for decoding filters // include class for decoding filters
@ -639,7 +639,7 @@ class TCPDF_PARSER {
$i = 0; // object main index $i = 0; // object main index
do { do {
// get element // get element
$element = $this->getRawObject($offset); print_r($element);//DEBUG $element = $this->getRawObject($offset);
$offset = $element[2]; $offset = $element[2];
// decode stream using stream's dictionary information // decode stream using stream's dictionary information
if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) { if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {
@ -721,7 +721,11 @@ class TCPDF_PARSER {
$remaining_filters = array(); $remaining_filters = array();
foreach ($filters as $filter) { foreach ($filters as $filter) {
if (in_array($filter, $this->FilterDecoders->getAvailableFilters())) { if (in_array($filter, $this->FilterDecoders->getAvailableFilters())) {
$stream = $this->FilterDecoders->decodeFilter($filter, $stream); try {
$stream = $this->FilterDecoders->decodeFilter($filter, $stream);
} catch (Exception $e) {
$this->Error($e->getMessage());
}
} else { } else {
// add missing filter to array // add missing filter to array
$remaining_filters[] = $filter; $remaining_filters[] = $filter;
@ -731,14 +735,17 @@ class TCPDF_PARSER {
} }
/** /**
* This method is automatically called in case of fatal error; it simply outputs the message and halts the execution. * Throw an exception or print an error message and die if the K_TCPDF_PARSER_THROW_EXCEPTION_ERROR constant is set to true.
* @param $msg (string) The error message * @param $msg (string) The error message
* @public * @public
* @since 1.0.000 (2011-05-23) * @since 1.0.000 (2011-05-23)
*/ */
public function Error($msg) { public function Error($msg) {
// exit program and print error if (defined('K_TCPDF_PARSER_THROW_EXCEPTION_ERROR') AND !K_TCPDF_PARSER_THROW_EXCEPTION_ERROR) {
die('<strong>TCPDF_PARSER ERROR: </strong>'.$msg); die('<strong>TCPDF_PARSER ERROR: </strong>'.$msg);
} else {
throw new Exception('TCPDF_PARSER ERROR: '.$msg);
}
} }
} // END OF TCPDF_PARSER CLASS } // END OF TCPDF_PARSER CLASS