/**
  * Dereference.
  * Take inderect object, take $value member of this object (must be \ZendPdf\InternalType\AbstractTypeObject),
  * take reference to the $value member of this object and assign it to
  * $value member of current PDF Reference object
  * $obj can be null
  *
  * @throws \ZendPdf\Exception\ExceptionInterface
  */
 private function _dereference()
 {
     if (($obj = $this->_factory->fetchObject($this->_objNum . ' ' . $this->_genNum)) === null) {
         $obj = $this->_context->getParser()->getObject($this->_context->getRefTable()->getOffset($this->_objNum . ' ' . $this->_genNum . ' R'), $this->_context);
     }
     if ($obj === null) {
         $this->_ref = new NullObject();
         return;
     }
     if ($obj->toString() != $this->_objNum . ' ' . $this->_genNum . ' R') {
         throw new Exception\RuntimeException('Incorrect reference to the object');
     }
     $this->_ref = $obj;
 }
Example #2
0
 /**
  * Get header of free objects list
  * Returns object number of last free object
  *
  * @throws \ZendPdf\Exception\ExceptionInterface
  * @return integer
  */
 public function getLastFreeObject()
 {
     try {
         $this->_context->getRefTable()->getNextFree('0 65535 R');
     } catch (Exception\ExceptionInterface $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 $e;
     }
 }