diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT
index 8180e64..e94df58 100644
--- a/CHANGELOG.TXT
+++ b/CHANGELOG.TXT
@@ -1,7 +1,12 @@
+6.0.029 (2013-09-15)
+ - Constants K_TCPDF_PARSER_THROW_EXCEPTION_ERROR and K_TCPDF_PARSER_IGNORE_DECODING_ERRORS where removed in favor of a new configuration array in the TCPDF_PARSER class.
+ - The TCPDF_PARSER class can now be configured using the new $cfg parameter.
+
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.
+ - TCPDF_FILTERS class now throws an exception in case of error.
+ - TCPDF_PARSER class now throws an exception in case of error unless you define the constant K_TCPDF_PARSER_THROW_EXCEPTION_ERROR to false.
+ - The constant K_TCPDF_PARSER_IGNORE_DECODING_ERRORS can be set to tru eto ignore decoding errors on TCPDF_PARSER.
6.0.027 (2013-09-14)
- A bug in tcpdf_parser wen parsing hexadecimal strings was fixed.
diff --git a/README.TXT b/README.TXT
index 6c4d01e..62cfa63 100644
--- a/README.TXT
+++ b/README.TXT
@@ -8,7 +8,7 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
-Version: 6.0.028
+Version: 6.0.029
Release date: 2013-09-15
Author: Nicola Asuni
diff --git a/composer.json b/composer.json
index 706c582..27e71b4 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "tecnick.com/tcpdf",
- "version": "6.0.028",
+ "version": "6.0.029",
"homepage": "http://www.tcpdf.org/",
"type": "library",
"description": "TCPDF is a PHP class for generating PDF documents.",
diff --git a/include/tcpdf_filters.php b/include/tcpdf_filters.php
index 6b4fbe2..28556e4 100644
--- a/include/tcpdf_filters.php
+++ b/include/tcpdf_filters.php
@@ -406,7 +406,7 @@ class TCPDF_FILTERS {
* @public static
*/
public static function decodeFilterCCITTFaxDecode($data) {
- self::Error('decodeFilterCCITTFaxDecode: this method has not been yet implemented');
+ self::Error('~decodeFilterCCITTFaxDecode: this method has not been yet implemented');
//return $data;
}
@@ -419,7 +419,7 @@ class TCPDF_FILTERS {
* @public static
*/
public static function decodeFilterJBIG2Decode($data) {
- self::Error('decodeFilterJBIG2Decode: this method has not been yet implemented');
+ self::Error('~decodeFilterJBIG2Decode: this method has not been yet implemented');
//return $data;
}
@@ -432,7 +432,7 @@ class TCPDF_FILTERS {
* @public static
*/
public static function decodeFilterDCTDecode($data) {
- self::Error('decodeFilterDCTDecode: this method has not been yet implemented');
+ self::Error('~decodeFilterDCTDecode: this method has not been yet implemented');
//return $data;
}
@@ -445,7 +445,7 @@ class TCPDF_FILTERS {
* @public static
*/
public static function decodeFilterJPXDecode($data) {
- self::Error('decodeFilterJPXDecode: this method has not been yet implemented');
+ self::Error('~decodeFilterJPXDecode: this method has not been yet implemented');
//return $data;
}
@@ -458,7 +458,7 @@ class TCPDF_FILTERS {
* @public static
*/
public static function decodeFilterCrypt($data) {
- self::Error('decodeFilterCrypt: this method has not been yet implemented');
+ self::Error('~decodeFilterCrypt: this method has not been yet implemented');
//return $data;
}
diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php
index 93a572a..a374e47 100644
--- a/include/tcpdf_static.php
+++ b/include/tcpdf_static.php
@@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
- private static $tcpdf_version = '6.0.028';
+ private static $tcpdf_version = '6.0.029';
/**
* String alias for total number of pages.
diff --git a/tcpdf.php b/tcpdf.php
index 47185e5..d6d42c1 100644
--- a/tcpdf.php
+++ b/tcpdf.php
@@ -1,7 +1,7 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
- * @version 6.0.028
+ * @version 6.0.029
*/
// 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.
* @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions.
- * @version 6.0.028
+ * @version 6.0.029
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
diff --git a/tcpdf_parser.php b/tcpdf_parser.php
index b8e998d..cdf70f6 100644
--- a/tcpdf_parser.php
+++ b/tcpdf_parser.php
@@ -1,7 +1,7 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
- * @version 1.0.006
+ * @version 1.0.007
*/
// include class for decoding filters
@@ -77,18 +77,43 @@ class TCPDF_PARSER {
*/
private $FilterDecoders;
+ /**
+ * Array of configuration parameters.
+ * @private
+ */
+ private $cfg = array(
+ 'die_for_errors' => false,
+ 'ignore_filter_decoding_errors' => true,
+ 'ignore_missing_filter_decoders' => true,
+ );
+
// -----------------------------------------------------------------------------
/**
* Parse a PDF document an return an array of objects.
* @param $data (string) PDF data to parse.
+ * @param $cfg (array) Array of configuration parameters:
+ * 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception;
+ * 'ignore_filter_decoding_errors' : if true ignore filter decoding errors;
+ * 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors.
* @public
* @since 1.0.000 (2011-05-24)
*/
- public function __construct($data) {
+ public function __construct($data, $cfg=array()) {
if (empty($data)) {
$this->Error('Empty PDF data.');
}
+ // set configuration parameters
+ if (isset($cfg['die_for_errors'])) {
+ $this->cfg['die_for_errors'] = !!$cfg['die_for_errors'];
+ }
+ if (isset($cfg['ignore_filter_decoding_errors'])) {
+ $this->cfg['ignore_filter_decoding_errors'] = !!$cfg['ignore_filter_decoding_errors'];
+ }
+ if (isset($cfg['ignore_missing_filter_decoders'])) {
+ $this->cfg['ignore_missing_filter_decoders'] = !!$cfg['ignore_missing_filter_decoders'];
+ }
+ // get PDF content string
$this->pdfdata = $data;
// get length
$pdflen = strlen($this->pdfdata);
@@ -210,7 +235,6 @@ class TCPDF_PARSER {
}
if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
$xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]);
- $this->Error('Encrypted documents are not supported!');
}
if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
$xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]);
@@ -724,7 +748,11 @@ class TCPDF_PARSER {
try {
$stream = $this->FilterDecoders->decodeFilter($filter, $stream);
} catch (Exception $e) {
- $this->Error($e->getMessage());
+ $emsg = $e->getMessage();
+ if ((($emsg[0] == '~') AND !$this->cfg['ignore_missing_filter_decoders'])
+ OR (($emsg[0] != '~') AND !$this->cfg['ignore_filter_decoding_errors'])) {
+ $this->Error($e->getMessage());
+ }
}
} else {
// add missing filter to array
@@ -741,7 +769,7 @@ class TCPDF_PARSER {
* @since 1.0.000 (2011-05-23)
*/
public function Error($msg) {
- if (defined('K_TCPDF_PARSER_THROW_EXCEPTION_ERROR') AND !K_TCPDF_PARSER_THROW_EXCEPTION_ERROR) {
+ if ($this->cfg['die_for_errors']) {
die('TCPDF_PARSER ERROR: '.$msg);
} else {
throw new Exception('TCPDF_PARSER ERROR: '.$msg);