⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @package    Zend_Pdf * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License *//** Zend_Pdf_Exception */require_once 'Zend/Pdf/Exception.php';/** Zend_Pdf_Resource_Font */require_once 'Zend/Pdf/Resource/Font.php';/** Zend_Pdf_Style */require_once 'Zend/Pdf/Style.php';/** Zend_Pdf_Element_Dictionary */require_once 'Zend/Pdf/Element/Dictionary.php';/** Zend_Pdf_Element_Reference */require_once 'Zend/Pdf/Element/Reference.php';/** Zend_Pdf_ElementFactory */require_once 'Zend/Pdf/ElementFactory.php';/** Zend_Pdf_Color */require_once 'Zend/Pdf/Color.php';/** Zend_Pdf_Color_GrayScale */require_once 'Zend/Pdf/Color/GrayScale.php';/** Zend_Pdf_Color_Rgb */require_once 'Zend/Pdf/Color/Rgb.php';/** Zend_Pdf_Color_Cmyk */require_once 'Zend/Pdf/Color/Cmyk.php';/** * PDF Page * * @package    Zend_Pdf * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License */class Zend_Pdf_Page{  /**** Class Constants ****/  /* Page Sizes */    /**     * Size representing an A4 page in portrait (tall) orientation.     */    const SIZE_A4                = '595:842:';    /**     * Size representing an A4 page in landscape (wide) orientation.     */    const SIZE_A4_LANDSCAPE      = '842:595:';    /**     * Size representing a US Letter page in portrait (tall) orientation.     */    const SIZE_LETTER            = '612:792:';    /**     * Size representing a US Letter page in landscape (wide) orientation.     */    const SIZE_LETTER_LANDSCAPE  = '792:612:';  /* Shape Drawing */    /**     * Stroke the path only. Do not fill.     */    const SHAPE_DRAW_STROKE      = 0;    /**     * Fill the path only. Do not stroke.     */    const SHAPE_DRAW_FILL        = 1;    /**     * Fill and stroke the path.     */    const SHAPE_DRAW_FILL_AND_STROKE = 2;  /* Shape Filling Methods */    /**     * Fill the path using the non-zero winding rule.     */    const FILL_METHOD_NON_ZERO_WINDING = 0;    /**     * Fill the path using the even-odd rule.     */    const FILL_METHOD_EVEN_ODD        = 1;  /* Line Dash Types */    /**     * Solid line dash.     */    const LINE_DASHING_SOLID = 0;    /**     * Reference to the object with page dictionary.     *     * @var Zend_Pdf_Element_Reference     */    private $_pageDictionary;    /**     * PDF objects factory.     *     * @var Zend_Pdf_ElementFactory_Interface     */    private $_objFactory = null;    /**     * Flag which signals, that page is created separately from any PDF document or     * attached to anyone.     *     * @var boolean     */    private $_attached;    /**     * Stream of the drawing instractions.     *     * @var string     */    private $_contents = '';    /**     * Current style     *     * @var Zend_Pdf_Style     */    private $_style = null;    /**     * Counter for the "Save" operations     *     * @var integer     */    private $_saveCount = 0;
    /**
     * Safe Graphics State semafore
     * 
     * If it's false, than we can't be sure Graphics State is restored withing 
     * context of previous contents stream (ex. drawing coordinate system may be rotated).
     * We should encompass existing content with save/restore GS operators
     * 
     * @var boolean 
     */
    private $_safeGS;
    /**     * Current font     *     * @var Zend_Pdf_Resource_Font     */    private $_font = null;    /**     * Current font size     *     * @var float     */    private $_fontSize;    /**     * 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_Interface $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_Interface $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_Interface $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_Interface &&            $param3 === null           ) {            $this->_pageDictionary = $param1;            $this->_objFactory     = $param2;            $this->_attached       = true;
            $this->_safeGS         = false;
            return;        } else if ($param1 instanceof Zend_Pdf_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 Zend_Pdf_Element_Dictionary());            foreach ($param1->_pageDictionary->getKeys() as $key) {                if ($key == 'Contents') {                    // Clone Contents property                    $this->_pageDictionary->Contents = new Zend_Pdf_Element_Array();                    if ($param1->_pageDictionary->Contents->getType() != Zend_Pdf_Element::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 Zend_Pdf_ElementFactory_Interface) &&                   $param3 === null) {            $this->_objFactory = ($param2 !== null)? $param2 : Zend_Pdf_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 = Zend_Pdf_Page::SIZE_A4;                    break;                case 'a4-landscape':                    $param1 = Zend_Pdf_Page::SIZE_A4_LANDSCAPE;                    break;                case 'letter':                    $param1 = Zend_Pdf_Page::SIZE_LETTER;                    break;                case 'letter-landscape':                    $param1 = Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE;                    break;                default:                    // should be in "x:y" form            }            $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_Interface)) {            $this->_objFactory = ($param3 !== null)? $param3 : Zend_Pdf_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 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::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();    }    /**     * Clone operator     *     * @throws Zend_Pdf_Exception     */    public function __clone()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -