diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT
index d39f102..856e568 100755
--- a/CHANGELOG.TXT
+++ b/CHANGELOG.TXT
@@ -1,3 +1,6 @@
+5.9.160 (2012-05-03)
+ - A bug on tcpdf_parser.php was fixed.
+
5.9.159 (2012-04-30)
- Barcode classes were updated to fix PNG export Bug (ID: 3522291).
diff --git a/README.TXT b/README.TXT
index 57a996e..cc1218d 100755
--- a/README.TXT
+++ b/README.TXT
@@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
-Version: 5.9.159
-Release date: 2012-04-30
+Version: 5.9.160
+Release date: 2012-05-03
Author: Nicola Asuni
Copyright (c) 2002-2012:
diff --git a/tcpdf.php b/tcpdf.php
index f9d82fa..1eb13c4 100755
--- a/tcpdf.php
+++ b/tcpdf.php
@@ -1,9 +1,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
- * @version 5.9.159
+ * @version 5.9.160
*/
// Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@@ -149,7 +149,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.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 5.9.159
+ * @version 5.9.160
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF {
@@ -160,7 +160,7 @@ class TCPDF {
* Current TCPDF version.
* @private
*/
- private $tcpdf_version = '5.9.159';
+ private $tcpdf_version = '5.9.160';
// Protected properties
diff --git a/tcpdf_parser.php b/tcpdf_parser.php
index 1226760..f17359f 100644
--- a/tcpdf_parser.php
+++ b/tcpdf_parser.php
@@ -1,9 +1,9 @@
* @package com.tecnick.tcpdf
* @author Nicola Asuni
- * @version 1.0.000
+ * @version 1.0.001
*/
// include class for decoding filters
@@ -48,7 +48,7 @@ require_once(dirname(__FILE__).'/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.000
+ * @version 1.0.001
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF_PARSER {
@@ -127,20 +127,29 @@ class TCPDF_PARSER {
* @since 1.0.000 (2011-05-24)
*/
protected function getXrefData($offset=0, $xref=array()) {
- // find last startxref
- if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
- $this->Error('Unable to find startxref');
+ if ($offset == 0) {
+ // find last startxref
+ if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
+ $this->Error('Unable to find startxref');
+ }
+ $matches = array_pop($matches);
+ $startxref = $matches[1];
+ } else {
+ // get the first xref at the specified offset
+ if (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) == 0) {
+ $this->Error('Unable to find startxref');
+ }
+ $startxref = $matches[1][0];
}
- $matches = array_pop($matches);
- $startxref = $matches[1];
// check xref position
if (strpos($this->pdfdata, 'xref', $startxref) != $startxref) {
$this->Error('Unable to find xref');
}
// extract xref data (object indexes and offsets)
- $offset = $startxref + 5;
+ $xoffset = $startxref + 5;
// initialize object number
$obj_num = 0;
+ $offset = $xoffset;
while (preg_match('/^([0-9]+)[\s]([0-9]+)[\s]?([nf]?)/im', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$offset = (strlen($matches[0][0]) + $matches[0][1]);
if ($matches[3][0] == 'n') {
@@ -162,7 +171,7 @@ class TCPDF_PARSER {
}
}
// get trailer data
- if (preg_match('/trailer[\s]*<<(.*)>>[\s]*[\r\n]+startxref[\s]*[\r\n]+/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
+ if (preg_match('/trailer[\s]*<<(.*)>>[\s]*[\r\n]+startxref[\s]*[\r\n]+/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $xoffset) > 0) {
$trailer_data = $matches[1][0];
if (!isset($xref['trailer'])) {
// get only the last updated version
@@ -188,7 +197,7 @@ class TCPDF_PARSER {
}
if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
// get previous xref
- $xref = getXrefData(substr($this->pdfdata, 0, $startxref), intval($matches[1]), $xref);
+ $xref = $this->getXrefData(intval($matches[1]), $xref);
}
} else {
$this->Error('Unable to find trailer');
@@ -399,7 +408,7 @@ class TCPDF_PARSER {
$offset = $element[2];
// decode stream using stream's dictionary information
if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {
- $element[3] = $this->decodeStream($objdata[($i - 1)][1], $element[1]);
+ $element[3] = $this->decodeStream($objdata[($i - 1)][1], substr($element[1], 1));
}
$objdata[$i] = $element;
++$i;