/framework/vendor/zend/Zend/Pdf/Destination/FitRectangle.php
PHP | 171 lines | 62 code | 16 blank | 93 comment | 4 complexity | 82dc720d68f4892c76bc67182858393a MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
1<?php 2/** 3 * Zend Framework 4 * 5 * LICENSE 6 * 7 * This source file is subject to the new BSD license that is bundled 8 * with this package in the file LICENSE.txt. 9 * It is also available through the world-wide-web at this URL: 10 * http://framework.zend.com/license/new-bsd 11 * If you did not receive a copy of the license and are unable to 12 * obtain it through the world-wide-web, please send an email 13 * to license@zend.com so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Pdf 17 * @subpackage Destination 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id: FitRectangle.php 20096 2010-01-06 02:05:09Z bkarwin $ 21 */ 22 23 24/** Internally used classes */ 25require_once 'Zend/Pdf/Element/Array.php'; 26require_once 'Zend/Pdf/Element/Name.php'; 27require_once 'Zend/Pdf/Element/Numeric.php'; 28 29 30/** Zend_Pdf_Destination_Explicit */ 31require_once 'Zend/Pdf/Destination/Explicit.php'; 32 33/** 34 * Zend_Pdf_Destination_FitRectangle explicit detination 35 * 36 * Destination array: [page /FitR left bottom right top] 37 * 38 * Display the page designated by page, with its contents magnified just enough 39 * to fit the rectangle specified by the coordinates left, bottom, right, and top 40 * entirely within the window both horizontally and vertically. If the required 41 * horizontal and vertical magnification factors are different, use the smaller of 42 * the two, centering the rectangle within the window in the other dimension. 43 * 44 * @package Zend_Pdf 45 * @subpackage Destination 46 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 47 * @license http://framework.zend.com/license/new-bsd New BSD License 48 */ 49class Zend_Pdf_Destination_FitRectangle extends Zend_Pdf_Destination_Explicit 50{ 51 /** 52 * Create destination object 53 * 54 * @param Zend_Pdf_Page|integer $page Page object or page number 55 * @param float $left Left edge of displayed page 56 * @param float $bottom Bottom edge of displayed page 57 * @param float $right Right edge of displayed page 58 * @param float $top Top edge of displayed page 59 * @return Zend_Pdf_Destination_FitRectangle 60 * @throws Zend_Pdf_Exception 61 */ 62 public static function create($page, $left, $bottom, $right, $top) 63 { 64 $destinationArray = new Zend_Pdf_Element_Array(); 65 66 if ($page instanceof Zend_Pdf_Page) { 67 $destinationArray->items[] = $page->getPageDictionary(); 68 } else if (is_integer($page)) { 69 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page); 70 } else { 71 require_once 'Zend/Pdf/Exception.php'; 72 throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.'); 73 } 74 75 $destinationArray->items[] = new Zend_Pdf_Element_Name('FitR'); 76 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left); 77 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($bottom); 78 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($right); 79 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top); 80 81 return new Zend_Pdf_Destination_FitRectangle($destinationArray); 82 } 83 84 /** 85 * Get left edge of the displayed page 86 * 87 * @return float 88 */ 89 public function getLeftEdge() 90 { 91 return $this->_destinationArray->items[2]->value; 92 } 93 94 /** 95 * Set left edge of the displayed page 96 * 97 * @param float $left 98 * @return Zend_Pdf_Action_FitRectangle 99 */ 100 public function setLeftEdge($left) 101 { 102 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left); 103 return $this; 104 } 105 106 /** 107 * Get bottom edge of the displayed page 108 * 109 * @return float 110 */ 111 public function getBottomEdge() 112 { 113 return $this->_destinationArray->items[3]->value; 114 } 115 116 /** 117 * Set bottom edge of the displayed page 118 * 119 * @param float $bottom 120 * @return Zend_Pdf_Action_FitRectangle 121 */ 122 public function setBottomEdge($bottom) 123 { 124 $this->_destinationArray->items[3] = new Zend_Pdf_Element_Numeric($bottom); 125 return $this; 126 } 127 128 /** 129 * Get right edge of the displayed page 130 * 131 * @return float 132 */ 133 public function getRightEdge() 134 { 135 return $this->_destinationArray->items[4]->value; 136 } 137 138 /** 139 * Set right edge of the displayed page 140 * 141 * @param float $right 142 * @return Zend_Pdf_Action_FitRectangle 143 */ 144 public function setRightEdge($right) 145 { 146 $this->_destinationArray->items[4] = new Zend_Pdf_Element_Numeric($right); 147 return $this; 148 } 149 150 /** 151 * Get top edge of the displayed page 152 * 153 * @return float 154 */ 155 public function getTopEdge() 156 { 157 return $this->_destinationArray->items[5]->value; 158 } 159 160 /** 161 * Set top edge of the displayed page 162 * 163 * @param float $top 164 * @return Zend_Pdf_Action_FitRectangle 165 */ 166 public function setTopEdge($top) 167 { 168 $this->_destinationArray->items[5] = new Zend_Pdf_Element_Numeric($top); 169 return $this; 170 } 171}