Example #1
0
    /**
     * Object constructor.
     */
    public function __construct()
    {
        parent::__construct('');

        $this->_resource->dictionary->Type    = new Zend_Pdf_Element_Name('XObject');
        $this->_resource->dictionary->Subtype = new Zend_Pdf_Element_Name('Image');
    }
Example #2
0
 /**
  * Object constructor.
  *
  * @param Zend_Pdf_Element_Object_Stream|string $contentStreamObject
  * @throws Zend_Pdf_Exception
  */
 public function __construct($contentStreamObject = '')
 {
     if ($contentStreamObject !== null && !$contentStreamObject instanceof Zend_Pdf_Element_Object_Stream && !is_string($contentStreamObject)) {
         require_once PHP_LIBRARY_PATH . 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Content stream parameter must be a string or stream object');
     }
     parent::__construct($contentStreamObject);
 }
Example #3
0
 /**
  * Object constructor.
  *
  * @param Zend_Pdf_Element_Object $extGStateObject
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element_Object $extGStateObject = null)
 {
     if ($extGStateObject == null) {
         // Create new Graphics State object
         require_once 'Zend/Pdf/ElementFactory.php';
         $factory = Zend_Pdf_ElementFactory::createFactory(1);
         $gsDictionary = new Zend_Pdf_Element_Dictionary();
         $gsDictionary->Type = new Zend_Pdf_Element_Name('ExtGState');
         $extGStateObject = $factory->newObject($gsDictionary);
     }
     if ($extGStateObject->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Graphics state PDF object must be a dictionary');
     }
     parent::__construct($gsDictionary);
 }
Example #4
0
 /**
  * Attach resource to the canvas
  *
  * Method returns a name of the resource which can be used
  * as a resource reference within drawing instructions stream
  * Allowed types: 'ExtGState', 'ColorSpace', 'Pattern', 'Shading',
  * 'XObject', 'Font', 'Properties'
  *
  * @param string $type
  * @param Zend_Pdf_Resource $resource
  * @return string
  */
 protected function _attachResource($type, Zend_Pdf_Resource $resource)
 {
     // Check, that resource is already attached to resource set.
     $resObject = $resource->getResource();
     foreach ($this->_resources[$type] as $resName => $collectedResObject) {
         if ($collectedResObject === $resObject) {
             return $resName;
         }
     }
     $idCounter = 1;
     do {
         $newResName = $type[0] . $idCounter++;
     } while (isset($this->_resources[$type][$newResName]));
     $this->_resources[$type][$newResName] = $resObject;
     return $newResName;
 }
Example #5
0
 /**
  * Attach resource to the page
  *
  * @param string $type
  * @param Zend_Pdf_Resource $resource
  * @return string
  */
 protected function _attachResource($type, Zend_Pdf_Resource $resource)
 {
     // Check that Resources dictionary contains appropriate resource set
     if ($this->_pageDictionary->Resources->{$type} === null) {
         $this->_pageDictionary->Resources->touch();
         $this->_pageDictionary->Resources->{$type} = new Zend_Pdf_Element_Dictionary();
     } 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;
 }
Example #6
0
 /**
  * Object constructor.
  *
  */
 public function __construct()
 {
     parent::__construct(new Zend_Pdf_Element_Dictionary());
     $this->_resource->Type = new Zend_Pdf_Element_Name('Font');
 }
Example #7
0
 /**
  * Object constructor.
  *
  * The $embeddingOptions parameter allows you to set certain flags related
  * to font embedding. You may combine options by OR-ing them together. See
  * the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
  * available options and their descriptions.
  *
  * @param integer $embeddingOptions (optional) Options for font embedding.
  *   Only used for certain font types.
  */
 public function __construct($embeddingOptions = 0)
 {
     parent::__construct(new Zend_Pdf_Element_Dictionary());
     $this->_resource->Type = new Zend_Pdf_Element_Name('Font');
     $this->_embeddingOptions = $embeddingOptions;
 }