|
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: Zoom.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** Internally used classes */ |
|
24 require_once 'Zend/Pdf/Element/Array.php'; |
|
25 require_once 'Zend/Pdf/Element/Name.php'; |
|
26 require_once 'Zend/Pdf/Element/Null.php'; |
|
27 require_once 'Zend/Pdf/Element/Numeric.php'; |
|
28 |
|
29 |
|
30 /** Zend_Pdf_Destination_Explicit */ |
|
31 require_once 'Zend/Pdf/Destination/Explicit.php'; |
|
32 |
|
33 /** |
|
34 * Zend_Pdf_Destination_Zoom explicit detination |
|
35 * |
|
36 * Destination array: [page /XYZ left top zoom] |
|
37 * |
|
38 * Display the page designated by page, with the coordinates (left, top) positioned |
|
39 * at the upper-left corner of the window and the contents of the page |
|
40 * magnified by the factor zoom. A null value for any of the parameters left, top, |
|
41 * or zoom specifies that the current value of that parameter is to be retained unchanged. |
|
42 * A zoom value of 0 has the same meaning as a null value. |
|
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 */ |
|
49 class Zend_Pdf_Destination_Zoom 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 $top Top edge of displayed page |
|
57 * @param float $zoom Zoom factor |
|
58 * @return Zend_Pdf_Destination_Zoom |
|
59 * @throws Zend_Pdf_Exception |
|
60 */ |
|
61 public static function create($page, $left = null, $top = null, $zoom = null) |
|
62 { |
|
63 $destinationArray = new Zend_Pdf_Element_Array(); |
|
64 |
|
65 if ($page instanceof Zend_Pdf_Page) { |
|
66 $destinationArray->items[] = $page->getPageDictionary(); |
|
67 } else if (is_integer($page)) { |
|
68 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page); |
|
69 } else { |
|
70 require_once 'Zend/Pdf/Exception.php'; |
|
71 throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.'); |
|
72 } |
|
73 |
|
74 $destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ'); |
|
75 |
|
76 if ($left === null) { |
|
77 $destinationArray->items[] = new Zend_Pdf_Element_Null(); |
|
78 } else { |
|
79 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left); |
|
80 } |
|
81 |
|
82 if ($top === null) { |
|
83 $destinationArray->items[] = new Zend_Pdf_Element_Null(); |
|
84 } else { |
|
85 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top); |
|
86 } |
|
87 |
|
88 if ($zoom === null) { |
|
89 $destinationArray->items[] = new Zend_Pdf_Element_Null(); |
|
90 } else { |
|
91 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom); |
|
92 } |
|
93 |
|
94 return new Zend_Pdf_Destination_Zoom($destinationArray); |
|
95 } |
|
96 |
|
97 /** |
|
98 * Get left edge of the displayed page (null means viewer application 'current value') |
|
99 * |
|
100 * @return float |
|
101 */ |
|
102 public function getLeftEdge() |
|
103 { |
|
104 return $this->_destinationArray->items[2]->value; |
|
105 } |
|
106 |
|
107 /** |
|
108 * Set left edge of the displayed page (null means viewer application 'current value') |
|
109 * |
|
110 * @param float $left |
|
111 * @return Zend_Pdf_Action_Zoom |
|
112 */ |
|
113 public function setLeftEdge($left) |
|
114 { |
|
115 if ($left === null) { |
|
116 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Null(); |
|
117 } else { |
|
118 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left); |
|
119 } |
|
120 |
|
121 return $this; |
|
122 } |
|
123 |
|
124 /** |
|
125 * Get top edge of the displayed page (null means viewer application 'current value') |
|
126 * |
|
127 * @return float |
|
128 */ |
|
129 public function getTopEdge() |
|
130 { |
|
131 return $this->_destinationArray->items[3]->value; |
|
132 } |
|
133 |
|
134 /** |
|
135 * Set top edge of the displayed page (null means viewer application 'current viewer') |
|
136 * |
|
137 * @param float $top |
|
138 * @return Zend_Pdf_Action_Zoom |
|
139 */ |
|
140 public function setTopEdge($top) |
|
141 { |
|
142 if ($top === null) { |
|
143 $this->_destinationArray->items[3] = new Zend_Pdf_Element_Null(); |
|
144 } else { |
|
145 $this->_destinationArray->items[3] = new Zend_Pdf_Element_Numeric($top); |
|
146 } |
|
147 |
|
148 return $this; |
|
149 } |
|
150 |
|
151 /** |
|
152 * Get ZoomFactor of the displayed page (null or 0 means viewer application 'current value') |
|
153 * |
|
154 * @return float |
|
155 */ |
|
156 public function getZoomFactor() |
|
157 { |
|
158 return $this->_destinationArray->items[4]->value; |
|
159 } |
|
160 |
|
161 /** |
|
162 * Set ZoomFactor of the displayed page (null or 0 means viewer application 'current viewer') |
|
163 * |
|
164 * @param float $zoom |
|
165 * @return Zend_Pdf_Action_Zoom |
|
166 */ |
|
167 public function setZoomFactor($zoom) |
|
168 { |
|
169 if ($zoom === null) { |
|
170 $this->_destinationArray->items[4] = new Zend_Pdf_Element_Null(); |
|
171 } else { |
|
172 $this->_destinationArray->items[4] = new Zend_Pdf_Element_Numeric($zoom); |
|
173 } |
|
174 |
|
175 return $this; |
|
176 } |
|
177 } |