diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Pdf/Trailer/Keeper.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Pdf/Trailer/Keeper.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,143 @@ +_context = $context; + $this->_prev = $prev; + } + + /** + * Setter for $this->_prev + * + * @param Zend_Pdf_Trailer_Keeper $prev + */ + public function setPrev(Zend_Pdf_Trailer_Keeper $prev) + { + $this->_prev = $prev; + } + + /** + * Getter for $this->_prev + * + * @return Zend_Pdf_Trailer + */ + public function getPrev() + { + return $this->_prev; + } + + /** + * Get length of source PDF + * + * @return string + */ + public function getPDFLength() + { + return $this->_context->getParser()->getLength(); + } + + /** + * Get PDF String + * + * @return string + */ + public function getPDFString() + { + return $this->_context->getParser()->getString(); + } + + /** + * Get reference table, which corresponds to the trailer. + * Proxy to the $_context member methad call + * + * @return Zend_Pdf_Element_Reference_Context + */ + public function getRefTable() + { + return $this->_context->getRefTable(); + } + + /** + * Get header of free objects list + * Returns object number of last free object + * + * @throws Zend_Pdf_Exception + * @return integer + */ + public function getLastFreeObject() + { + try { + $this->_context->getRefTable()->getNextFree('0 65535 R'); + } catch (Zend_Pdf_Exception $e) { + if ($e->getMessage() == 'Object not found.') { + /** + * Here is work around for some wrong generated PDFs. + * We have not found reference to the header of free object list, + * thus we treat it as there are no free objects. + */ + return 0; + } + + throw new Zend_Pdf_Exception($e->getMessage(), $e->getCode(), $e); + } + } +}