Exemple #1
0
 /**
  * Attach resource to the page
  *
  * @param string $type
  * @param \Zend\Pdf\Resource\AbstractResource $resource
  * @return string
  */
 protected function _attachResource($type, Resource\AbstractResource $resource)
 {
     // Check that Resources dictionary contains appropriate resource set
     if ($this->_pageDictionary->Resources->{$type} === null) {
         $this->_pageDictionary->Resources->touch();
         $this->_pageDictionary->Resources->{$type} = new InternalType\DictionaryObject();
     } else {
         $this->_pageDictionary->Resources->{$type}->touch();
     }
     // Check, that resource is already attached to resource set.
     $resObject = $resource->getResource();
     foreach ($this->_pageDictionary->Resources->{$type}->getKeys() as $ResID) {
         if ($this->_pageDictionary->Resources->{$type}->{$ResID} === $resObject) {
             return $ResID;
         }
     }
     $idCounter = 1;
     do {
         $newResName = $type[0] . $idCounter++;
     } while ($this->_pageDictionary->Resources->{$type}->{$newResName} !== null);
     $this->_pageDictionary->Resources->{$type}->{$newResName} = $resObject;
     $this->_objFactory->attach($resource->getFactory());
     return $newResName;
 }
Exemple #2
0
 /**
  * Prepare page to be rendered into PDF.
  *
  * @todo Don't forget to close all current graphics operations (like path drawing)
  *
  * @param \Zend\Pdf\ObjectFactory $objFactory
  * @throws \Zend\Pdf\Exception
  */
 public function render(ObjectFactory $objFactory)
 {
     $this->flush();
     if ($objFactory === $this->_objFactory) {
         // Page is already attached to the document.
         return;
     }
     if ($this->_attached) {
         throw new Exception\LogicException('Page is attached to other document. Use clone $page to get it context free.');
     } else {
         $objFactory->attach($this->_objFactory);
     }
 }
Exemple #3
0
 /**
  * Attach factory to the current;
  *
  * @param \Zend\Pdf\ObjectFactory $factory
  */
 public function attach(ObjectFactory $factory)
 {
     $this->_factory->attach($factory);
 }