diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 0d18b36..35518f7 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.035 (2013-09-25) + - TCPDF_PARSER class was improved. + 6.0.034 (2013-09-24) - Bug #839 "Error in xref parsing in mixed newline chars" was fixed. diff --git a/README.TXT b/README.TXT index 311089e..ece2d04 100644 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.034 -Release date: 2013-09-24 +Version: 6.0.035 +Release date: 2013-09-25 Author: Nicola Asuni Copyright (c) 2002-2013: diff --git a/composer.json b/composer.json index 39d2d8b..adcd632 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.034", + "version": "6.0.035", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 5c3bc12..a2e6eeb 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.034'; + private static $tcpdf_version = '6.0.035'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index 0f942cd..8491e3b 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.034 + * @version 6.0.035 */ // TCPDF configuration @@ -128,7 +128,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.034 + * @version 6.0.035 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { diff --git a/tcpdf_parser.php b/tcpdf_parser.php index 00bd3e9..666cb32 100644 --- a/tcpdf_parser.php +++ b/tcpdf_parser.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 1.0.009 + * @version 1.0.010 */ // include class for decoding filters @@ -48,7 +48,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_filters.php'); * This is a PHP class for parsing PDF documents.
* @package com.tecnick.tcpdf * @brief This is a PHP class for parsing PDF documents.. - * @version 1.0.009 + * @version 1.0.010 * @author Nicola Asuni - info@tecnick.com */ class TCPDF_PARSER { @@ -104,6 +104,35 @@ class TCPDF_PARSER { $this->Error('Empty PDF data.'); } // set configuration parameters + $this->setConfig($cfg); + // get PDF content string + $this->pdfdata = $data; + // get length + $pdflen = strlen($this->pdfdata); + // get xref and trailer data + $this->xref = $this->getXrefData(); + // parse all document objects + $this->objects = array(); + foreach ($this->xref['xref'] as $obj => $offset) { + if (!isset($this->objects[$obj]) AND ($offset > 0)) { + // decode objects with positive offset + $this->objects[$obj] = $this->getIndirectObject($obj, $offset, true); + } + } + // release some memory + unset($this->pdfdata); + $this->pdfdata = ''; + } + + /** + * Set the configuration parameters. + * @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 + */ + protected function setConfig($cfg) { if (isset($cfg['die_for_errors'])) { $this->cfg['die_for_errors'] = !!$cfg['die_for_errors']; } @@ -113,25 +142,6 @@ class TCPDF_PARSER { 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); - // initialize class for decoding filters - $this->FilterDecoders = new TCPDF_FILTERS(); - // get xref and trailer data - $this->xref = $this->getXrefData(); - // parse all document objects - $this->objects = array(); - foreach ($this->xref['xref'] as $obj => $offset) { - if (!isset($this->objects[$obj]) AND ($offset > 0)) { - // decode only objects with positive offset - $this->objects[$obj] = $this->getIndirectObject($obj, $offset, true); - } - } - // release some memory - unset($this->pdfdata); - $this->pdfdata = ''; } /** @@ -747,13 +757,13 @@ class TCPDF_PARSER { // decode the stream $remaining_filters = array(); foreach ($filters as $filter) { - if (in_array($filter, $this->FilterDecoders->getAvailableFilters())) { + if (in_array($filter, TCPDF_FILTERS::getAvailableFilters())) { try { - $stream = $this->FilterDecoders->decodeFilter($filter, $stream); + $stream = TCPDF_FILTERS::decodeFilter($filter, $stream); } catch (Exception $e) { $emsg = $e->getMessage(); if ((($emsg[0] == '~') AND !$this->cfg['ignore_missing_filter_decoders']) - OR (($emsg[0] != '~') AND !$this->cfg['ignore_filter_decoding_errors'])) { + OR (($emsg[0] != '~') AND !$this->cfg['ignore_filter_decoding_errors'])) { $this->Error($e->getMessage()); } }