예제 #1
0
 public function __construct()
 {
     parent::__construct();
     $this->OrderDate = time();
     $this->Author = "Scavix";
     $this->Creator = "Scavix";
     $this->Producer = "Scavix";
 }
예제 #2
0
파일: Page.php 프로젝트: narixx/zf2
 /**
  * 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\InternalType\DictionaryObject $pageDict,
  *                   \Zend\Pdf\InternalType\ObjectFactory $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\ObjectFactory $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\ObjectFactory $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 InternalType\IndirectObjectReference && $param1->getType() == InternalType\AbstractTypeObject::TYPE_DICTIONARY && $param2 instanceof ObjectFactory && $param3 === null) {
         $this->_pageDictionary = $param1;
         $this->_objFactory = $param2;
         $this->_attached = true;
         $this->_safeGS = false;
         return;
     } else {
         if ($param1 instanceof Page && $param2 === null && $param3 === null) {
             // Clone existing page.
             // Let already existing content and resources to be shared between pages
             // We don't give existing content modification functionality, so we don't need "deep copy"
             $this->_objFactory = $param1->_objFactory;
             $this->_attached =& $param1->_attached;
             $this->_safeGS = false;
             $this->_pageDictionary = $this->_objFactory->newObject(new InternalType\DictionaryObject());
             foreach ($param1->_pageDictionary->getKeys() as $key) {
                 if ($key == 'Contents') {
                     // Clone Contents property
                     $this->_pageDictionary->Contents = new InternalType\ArrayObject();
                     if ($param1->_pageDictionary->Contents->getType() != InternalType\AbstractTypeObject::TYPE_ARRAY) {
                         // Prepare array of content streams and add existing stream
                         $this->_pageDictionary->Contents->items[] = $param1->_pageDictionary->Contents;
                     } else {
                         // Clone array of the content streams
                         foreach ($param1->_pageDictionary->Contents->items as $srcContentStream) {
                             $this->_pageDictionary->Contents->items[] = $srcContentStream;
                         }
                     }
                 } else {
                     $this->_pageDictionary->{$key} = $param1->_pageDictionary->{$key};
                 }
             }
             return;
         } else {
             if (is_string($param1) && ($param2 === null || $param2 instanceof ObjectFactory) && $param3 === null) {
                 if ($param2 !== null) {
                     $this->_objFactory = $param2;
                 } else {
                     $this->_objFactory = ObjectFactory\ElementFactory::createFactory(1);
                 }
                 $this->_attached = false;
                 $this->_safeGS = true;
                 /** New page created. That's users App responsibility to track GS changes */
                 switch (strtolower($param1)) {
                     case 'a4':
                         $param1 = self::SIZE_A4;
                         break;
                     case 'a4-landscape':
                         $param1 = self::SIZE_A4_LANDSCAPE;
                         break;
                     case 'letter':
                         $param1 = self::SIZE_LETTER;
                         break;
                     case 'letter-landscape':
                         $param1 = self::SIZE_LETTER_LANDSCAPE;
                         break;
                     default:
                         // should be in "x:y" or "x:y:" form
                 }
                 $pageDim = explode(':', $param1);
                 if (count($pageDim) == 2 || 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 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 ObjectFactory)) {
                     if ($param3 !== null) {
                         $this->_objFactory = $param3;
                     } else {
                         $this->_objFactory = ObjectFactory\ElementFactory::createFactory(1);
                     }
                     $this->_attached = false;
                     $this->_safeGS = true;
                     /** New page created. That's users App responsibility to track GS changes */
                     $pageWidth = $param1;
                     $pageHeight = $param2;
                 } else {
                     throw new Exception('Unrecognized method signature, wrong number of arguments or wrong argument types.');
                 }
             }
         }
     }
     $this->_pageDictionary = $this->_objFactory->newObject(new InternalType\DictionaryObject());
     $this->_pageDictionary->Type = new InternalType\NameObject('Page');
     $this->_pageDictionary->LastModified = new InternalType\StringObject(PdfDocument::pdfDate());
     $this->_pageDictionary->Resources = new InternalType\DictionaryObject();
     $this->_pageDictionary->MediaBox = new InternalType\ArrayObject();
     $this->_pageDictionary->MediaBox->items[] = new InternalType\NumericObject(0);
     $this->_pageDictionary->MediaBox->items[] = new InternalType\NumericObject(0);
     $this->_pageDictionary->MediaBox->items[] = new InternalType\NumericObject($pageWidth);
     $this->_pageDictionary->MediaBox->items[] = new InternalType\NumericObject($pageHeight);
     $this->_pageDictionary->Contents = new InternalType\ArrayObject();
 }
예제 #3
0
/**
 * @shortcut <PdfDocument::RenderToFile>($filename)
 */
function writePdfToFile(PdfDocument $pdf_doc, $filename)
{
    $pdf_doc->RenderToFile($filename);
    return $filename;
}