File indexing completed on 2024-12-22 05:36:54
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Pdf 0017 * @subpackage Destination 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** Internally used classes */ 0024 // require_once 'Zend/Pdf/Element/Array.php'; 0025 // require_once 'Zend/Pdf/Element/Name.php'; 0026 // require_once 'Zend/Pdf/Element/Null.php'; 0027 // require_once 'Zend/Pdf/Element/Numeric.php'; 0028 0029 0030 /** Zend_Pdf_Destination_Explicit */ 0031 // require_once 'Zend/Pdf/Destination/Explicit.php'; 0032 0033 /** 0034 * Zend_Pdf_Destination_Zoom explicit detination 0035 * 0036 * Destination array: [page /XYZ left top zoom] 0037 * 0038 * Display the page designated by page, with the coordinates (left, top) positioned 0039 * at the upper-left corner of the window and the contents of the page 0040 * magnified by the factor zoom. A null value for any of the parameters left, top, 0041 * or zoom specifies that the current value of that parameter is to be retained unchanged. 0042 * A zoom value of 0 has the same meaning as a null value. 0043 * 0044 * @package Zend_Pdf 0045 * @subpackage Destination 0046 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0047 * @license http://framework.zend.com/license/new-bsd New BSD License 0048 */ 0049 class Zend_Pdf_Destination_Zoom extends Zend_Pdf_Destination_Explicit 0050 { 0051 /** 0052 * Create destination object 0053 * 0054 * @param Zend_Pdf_Page|integer $page Page object or page number 0055 * @param float $left Left edge of displayed page 0056 * @param float $top Top edge of displayed page 0057 * @param float $zoom Zoom factor 0058 * @return Zend_Pdf_Destination_Zoom 0059 * @throws Zend_Pdf_Exception 0060 */ 0061 public static function create($page, $left = null, $top = null, $zoom = null) 0062 { 0063 $destinationArray = new Zend_Pdf_Element_Array(); 0064 0065 if ($page instanceof Zend_Pdf_Page) { 0066 $destinationArray->items[] = $page->getPageDictionary(); 0067 } else if (is_integer($page)) { 0068 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page); 0069 } else { 0070 // require_once 'Zend/Pdf/Exception.php'; 0071 throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.'); 0072 } 0073 0074 $destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ'); 0075 0076 if ($left === null) { 0077 $destinationArray->items[] = new Zend_Pdf_Element_Null(); 0078 } else { 0079 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left); 0080 } 0081 0082 if ($top === null) { 0083 $destinationArray->items[] = new Zend_Pdf_Element_Null(); 0084 } else { 0085 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top); 0086 } 0087 0088 if ($zoom === null) { 0089 $destinationArray->items[] = new Zend_Pdf_Element_Null(); 0090 } else { 0091 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom); 0092 } 0093 0094 return new Zend_Pdf_Destination_Zoom($destinationArray); 0095 } 0096 0097 /** 0098 * Get left edge of the displayed page (null means viewer application 'current value') 0099 * 0100 * @return float 0101 */ 0102 public function getLeftEdge() 0103 { 0104 return $this->_destinationArray->items[2]->value; 0105 } 0106 0107 /** 0108 * Set left edge of the displayed page (null means viewer application 'current value') 0109 * 0110 * @param float $left 0111 * @return Zend_Pdf_Action_Zoom 0112 */ 0113 public function setLeftEdge($left) 0114 { 0115 if ($left === null) { 0116 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Null(); 0117 } else { 0118 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left); 0119 } 0120 0121 return $this; 0122 } 0123 0124 /** 0125 * Get top edge of the displayed page (null means viewer application 'current value') 0126 * 0127 * @return float 0128 */ 0129 public function getTopEdge() 0130 { 0131 return $this->_destinationArray->items[3]->value; 0132 } 0133 0134 /** 0135 * Set top edge of the displayed page (null means viewer application 'current viewer') 0136 * 0137 * @param float $top 0138 * @return Zend_Pdf_Action_Zoom 0139 */ 0140 public function setTopEdge($top) 0141 { 0142 if ($top === null) { 0143 $this->_destinationArray->items[3] = new Zend_Pdf_Element_Null(); 0144 } else { 0145 $this->_destinationArray->items[3] = new Zend_Pdf_Element_Numeric($top); 0146 } 0147 0148 return $this; 0149 } 0150 0151 /** 0152 * Get ZoomFactor of the displayed page (null or 0 means viewer application 'current value') 0153 * 0154 * @return float 0155 */ 0156 public function getZoomFactor() 0157 { 0158 return $this->_destinationArray->items[4]->value; 0159 } 0160 0161 /** 0162 * Set ZoomFactor of the displayed page (null or 0 means viewer application 'current viewer') 0163 * 0164 * @param float $zoom 0165 * @return Zend_Pdf_Action_Zoom 0166 */ 0167 public function setZoomFactor($zoom) 0168 { 0169 if ($zoom === null) { 0170 $this->_destinationArray->items[4] = new Zend_Pdf_Element_Null(); 0171 } else { 0172 $this->_destinationArray->items[4] = new Zend_Pdf_Element_Numeric($zoom); 0173 } 0174 0175 return $this; 0176 } 0177 }