当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Pdf_ElementFactory::newObject方法代码示例

本文整理汇总了PHP中Zend_Pdf_ElementFactory::newObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_ElementFactory::newObject方法的具体用法?PHP Zend_Pdf_ElementFactory::newObject怎么用?PHP Zend_Pdf_ElementFactory::newObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Pdf_ElementFactory的用法示例。


在下文中一共展示了Zend_Pdf_ElementFactory::newObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Object constructor.
  *
  * If resource is not a Zend_Pdf_Element object, then stream object with specified value is
  * generated.
  *
  * @param Zend_Pdf_Element|string $resource
  */
 public function __construct($resource)
 {
     $this->_processedFacories = array();
     $this->_objectFactory = new Zend_Pdf_ElementFactory(1);
     if ($resource instanceof Zend_Pdf_Element) {
         $this->_resource = $this->_objectFactory->newObject($resource);
     } else {
         $this->_resource = $this->_objectFactory->newStreamObject($resource);
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:Resource.php

示例2: __construct

 /**
  * Object constructor.
  * Constructor signatures:
  *
  * 1. Load PDF page from a parsed PDF file.
  *    Object factory is created by PDF parser.
  * ---------------------------------------------------------
  * new Zend_Pdf_Page(Zend_Pdf_Element_Dictionary $pageDict,
  *                   Zend_Pdf_ElementFactory     $factory);
  * ---------------------------------------------------------
  *
  * 2. Clone PDF page.
  *    New page is created in the same context as source page. Object factory is shared.
  *    Thus it will be attached to the document, but need to be placed into Zend_Pdf::$pages array
  *    to be included into output.
  * ---------------------------------------------------------
  * new Zend_Pdf_Page(Zend_Pdf_Page $page);
  * ---------------------------------------------------------
  *
  * 3. Create new page with a specified pagesize.
  *    If $factory is null then it will be created and page must be attached to the document to be
  *    included into output.
  * ---------------------------------------------------------
  * new Zend_Pdf_Page(string $pagesize, Zend_Pdf_ElementFactory $factory = null);
  * ---------------------------------------------------------
  *
  * 4. Create new page with a specified pagesize (in default user space units).
  *    If $factory is null then it will be created and page must be attached to the document to be
  *    included into output.
  * ---------------------------------------------------------
  * new Zend_Pdf_Page(numeric $width, numeric $height, Zend_Pdf_ElementFactory $factory = null);
  * ---------------------------------------------------------
  *
  *
  * @param mixed $param1
  * @param mixed $param2
  * @param mixed $param3
  * @throws Zend_Pdf_Exception
  */
 public function __construct($param1, $param2 = null, $param3 = null)
 {
     if ($param1 instanceof Zend_Pdf_Element_Reference && $param1->getType() == Zend_Pdf_Element::TYPE_DICTIONARY && $param2 instanceof Zend_Pdf_ElementFactory && $param3 === null) {
         $this->_pageDictionary = $param1;
         $this->_objFactory = $param2;
         $this->_attached = true;
         return;
     } else {
         if ($param1 instanceof Zend_Pdf_Page && $param2 === null && $param3 === null) {
             /** @todo implementation */
             throw new Zend_Pdf_Exception('Not implemented yet.');
         } else {
             if (is_string($param1) && ($param2 === null || $param2 instanceof Zend_Pdf_ElementFactory) && $param3 === null) {
                 $this->_objFactory = $param2 !== null ? $param2 : new Zend_Pdf_ElementFactory(1);
                 $this->_attached = false;
                 if (array_key_exists($param1, Zend_Pdf_Const::$pageSizeAliases)) {
                     $param1 = Zend_Pdf_Const::$pageSizeAliases[$param1];
                 }
                 $pageDim = explode(':', $param1);
                 if (count($pageDim) == 3) {
                     $pageWidth = $pageDim[0];
                     $pageHeight = $pageDim[1];
                 } else {
                     /**
                      * @todo support of user defined pagesize notations, like:
                      *       "210x297mm", "595x842", "8.5x11in", "612x792"
                      */
                     throw new Zend_Pdf_Exception('Wrong pagesize notation.');
                 }
                 /**
                  * @todo support of pagesize recalculation to "default user space units"
                  */
             } else {
                 if (is_numeric($param1) && is_numeric($param2) && ($param3 === null || $param3 instanceof Zend_Pdf_ElementFactory)) {
                     $this->_objFactory = $param3 !== null ? $param3 : new Zend_Pdf_ElementFactory(1);
                     $this->_attached = false;
                     $pageWidth = $param1;
                     $pageHeight = $param2;
                 } else {
                     throw new Zend_Pdf_Exception('Unrecognized method signature, wrong number of arguments or wrong argument types.');
                 }
             }
         }
     }
     $this->_pageDictionary = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());
     $this->_pageDictionary->Type = new Zend_Pdf_Element_Name('Page');
     $this->_pageDictionary->LastModified = new Zend_Pdf_Element_String(Zend_Pdf_Const::pdfDate());
     $this->_pageDictionary->Resources = new Zend_Pdf_Element_Dictionary();
     $this->_pageDictionary->MediaBox = new Zend_Pdf_Element_Array();
     $this->_pageDictionary->MediaBox->items[] = new Zend_Pdf_Element_Numeric(0);
     $this->_pageDictionary->MediaBox->items[] = new Zend_Pdf_Element_Numeric(0);
     $this->_pageDictionary->MediaBox->items[] = new Zend_Pdf_Element_Numeric($pageWidth);
     $this->_pageDictionary->MediaBox->items[] = new Zend_Pdf_Element_Numeric($pageHeight);
     $this->_pageDictionary->Contents = new Zend_Pdf_Element_Array();
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:94,代码来源:Page.php

示例3: makeClone

 /**
  * Detach PDF object from the factory (if applicable), clone it and attach to new factory.
  *
  * @param Zend_Pdf_ElementFactory $factory  The factory to attach
  * @param array &$processed  List of already processed indirect objects, used to avoid objects duplication
  * @param integer $mode  Cloning mode (defines filter for objects cloning)
  * @returns Zend_Pdf_Element
  */
 public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
 {
     $id = spl_object_hash($this);
     if (isset($processed[$id])) {
         // Do nothing if object is already processed
         // return it
         return $processed[$id];
     }
     // Create obect with null value and register it in $processed container
     $processed[$id] = $clonedObject = $factory->newObject(new Zend_Pdf_Element_Null());
     // Pecursively process actual data
     $clonedObject->_value = $this->_value->makeClone($factory, $processed, $mode);
     if ($clonedObject->_value instanceof Zend_Pdf_Element_Null) {
         // Do not store null objects within $processed container since it may be filtered
         // by $mode parameter but used in some future pass
         unset($processed[$id]);
         // Return direct null object
         return $clonedObject->_value;
     }
     return $clonedObject;
 }
开发者ID:fredcido,项目名称:cenbrap,代码行数:29,代码来源:Object.php

示例4: _loadPages

 /**
  * Load pages recursively
  *
  * @param Zend_Pdf_Element_Reference $pages
  * @param array|null $attributes
  */
 private function _loadPages(Zend_Pdf_Element_Reference $pages, $attributes = null)
 {
     static $inheritable = array('Resources', 'MediaBox', 'CropBox', 'Rotate');
     if ($pages->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         throw new Zend_Pdf_Exception('Wrong argument');
     }
     if ($attributes === null) {
         $attributes = array();
     }
     foreach ($pages->getKeys() as $property) {
         if (in_array($property, $inheritable)) {
             $attributes[$property] = $pages->{$property};
             $pages->{$property} = null;
         }
     }
     foreach ($pages->Kids->items as $child) {
         if ($child->Type->value == 'Pages') {
             $this->_loadPages($child, $attributes);
         } else {
             if ($child->Type->value == 'Page') {
                 foreach ($inheritable as $property) {
                     if ($child->{$property} === null && array_key_exists($property, $attributes)) {
                         /**
                          * Important note.
                          * If any attribute or dependant object is an indirect object, then it's still
                          * shared between pages.
                          */
                         if ($attributes[$property] instanceof Zend_Pdf_Element_Object) {
                             $child->{$property} = $attributes[$property];
                         } else {
                             $child->{$property} = $this->_objFactory->newObject($attributes[$property]);
                         }
                     }
                 }
                 $this->pages[] = new Zend_Pdf_Page($child, $this->_objFactory);
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:45,代码来源:Pdf.php

示例5: __construct

 /**
  * Creates or loads PDF document.
  *
  * If $source is null, then it creates a new document.
  *
  * If $source is a string and $load is false, then it loads document
  * from a binary string.
  *
  * If $source is a string and $load is true, then it loads document
  * from a file.
  * $revision used to roll back document to specified version
  * (0 - currtent version, 1 - previous version, 2 - ...)
  *
  * @param string  $source - PDF file to load
  * @param integer $revision
  * @throws Zend_Pdf_Exception
  */
 public function __construct(&$source = null, $revision = null, $load = false)
 {
     $this->_objFactory = new Zend_Pdf_ElementFactory(1);
     if ($source !== null) {
         $parser = new Zend_Pdf_Parser($source, $this->_objFactory, $load);
         $this->_trailer = $parser->getTrailer();
         if ($revision !== null) {
             $this->rollback($revision);
         } else {
             $this->_loadPages($this->_trailer->Root->Pages);
         }
     } else {
         $trailerDictionary = new Zend_Pdf_Element_Dictionary();
         /**
          * Document id
          */
         $docId = md5(uniqid(rand(), true));
         // 32 byte (128 bit) identifier
         $docIdLow = substr($docId, 0, 16);
         // first 16 bytes
         $docIdHigh = substr($docId, 16, 16);
         // second 16 bytes
         $trailerDictionary->ID = new Zend_Pdf_Element_Array();
         $trailerDictionary->ID->items[] = new Zend_Pdf_Element_String_Binary($docIdLow);
         $trailerDictionary->ID->items[] = new Zend_Pdf_Element_String_Binary($docIdHigh);
         $this->_trailer = new Zend_Pdf_Trailer_Generator($trailerDictionary);
         /**
          * Document catalog indirect object.
          */
         $docCatalog = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());
         $docCatalog->Type = new Zend_Pdf_Element_Name('Catalog');
         $docCatalog->Version = new Zend_Pdf_Element_Name(Zend_Pdf_Const::PDF_VERSION);
         $this->_trailer->Root = $docCatalog;
         /**
          * Pages container
          */
         $docPages = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());
         $docPages->Type = new Zend_Pdf_Element_Name('Pages');
         $docPages->Kids = new Zend_Pdf_Element_Array();
         $docPages->Count = new Zend_Pdf_Element_Numeric(0);
         $docCatalog->Pages = $docPages;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:60,代码来源:Pdf.php

示例6: makeClone

 public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
 {
     $id = spl_object_hash($this);
     if (isset($processed[$id])) {
         return $processed[$id];
     }
     $processed[$id] = $clonedObject = $factory->newObject(new Zend_Pdf_Element_Null());
     $clonedObject->_value = $this->_value->makeClone($factory, $processed, $mode);
     if ($clonedObject->_value instanceof Zend_Pdf_Element_Null) {
         unset($processed[$id]);
         return $clonedObject->_value;
     }
     return $clonedObject;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:14,代码来源:Pdf_Pack.php


注:本文中的Zend_Pdf_ElementFactory::newObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。