diff --git a/fpdi.php b/fpdi.php index 48223a3..d85842c 100644 --- a/fpdi.php +++ b/fpdi.php @@ -571,7 +571,7 @@ class FPDI extends FPDF_TPL reset ($value[1]); - while (list($k, $v) = each($value[1])) { + foreach ($value[1] as $k => $v) { $this->_straightOut($k . ' '); $this->_writeValue($v); } diff --git a/fpdi_pdf_parser.php b/fpdi_pdf_parser.php index a9622b0..7add424 100644 --- a/fpdi_pdf_parser.php +++ b/fpdi_pdf_parser.php @@ -218,16 +218,30 @@ class fpdi_pdf_parser extends pdf_parser if (!is_null($box) && $box[0] == pdf_parser::TYPE_ARRAY) { $b = $box[1]; - return array( - 'x' => $b[0][1] / $k, - 'y' => $b[1][1] / $k, - 'w' => abs($b[0][1] - $b[2][1]) / $k, - 'h' => abs($b[1][1] - $b[3][1]) / $k, - 'llx' => min($b[0][1], $b[2][1]) / $k, - 'lly' => min($b[1][1], $b[3][1]) / $k, - 'urx' => max($b[0][1], $b[2][1]) / $k, - 'ury' => max($b[1][1], $b[3][1]) / $k, - ); + if($k == NULL){ + return array( + 'x' => NAN, + 'y' => NAN, + 'w' => NAN, + 'h' => NAN, + 'llx' => NAN, + 'lly' => NAN, + 'urx' => NAN, + 'ury' => NAN, + ); + }else{ + return array( + 'x' => $b[0][1] / $k, + 'y' => $b[1][1] / $k, + 'w' => abs($b[0][1] - $b[2][1]) / $k, + 'h' => abs($b[1][1] - $b[3][1]) / $k, + 'llx' => min($b[0][1], $b[2][1]) / $k, + 'lly' => min($b[1][1], $b[3][1]) / $k, + 'urx' => max($b[0][1], $b[2][1]) / $k, + 'ury' => max($b[1][1], $b[3][1]) / $k, + ); + } + } else if (!isset($page[1][1]['/Parent'])) { return false; } else {