|
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: Destination.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 |
|
24 /** Internally used classes */ |
|
25 require_once 'Zend/Pdf/Element.php'; |
|
26 |
|
27 |
|
28 /** Zend_Pdf_Target */ |
|
29 require_once 'Zend/Pdf/Target.php'; |
|
30 |
|
31 |
|
32 /** |
|
33 * Abstract PDF destination representation class |
|
34 * |
|
35 * @package Zend_Pdf |
|
36 * @subpackage Destination |
|
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
39 */ |
|
40 abstract class Zend_Pdf_Destination extends Zend_Pdf_Target |
|
41 { |
|
42 /** |
|
43 * Load Destination object from a specified resource |
|
44 * |
|
45 * @internal |
|
46 * @param $destinationArray |
|
47 * @return Zend_Pdf_Destination |
|
48 */ |
|
49 public static function load(Zend_Pdf_Element $resource) |
|
50 { |
|
51 require_once 'Zend/Pdf/Element.php'; |
|
52 if ($resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) { |
|
53 require_once 'Zend/Pdf/Destination/Named.php'; |
|
54 return new Zend_Pdf_Destination_Named($resource); |
|
55 } |
|
56 |
|
57 if ($resource->getType() != Zend_Pdf_Element::TYPE_ARRAY) { |
|
58 require_once 'Zend/Pdf/Exception.php'; |
|
59 throw new Zend_Pdf_Exception('An explicit destination must be a direct or an indirect array object.'); |
|
60 } |
|
61 if (count($resource->items) < 2) { |
|
62 require_once 'Zend/Pdf/Exception.php'; |
|
63 throw new Zend_Pdf_Exception('An explicit destination array must contain at least two elements.'); |
|
64 } |
|
65 |
|
66 switch ($resource->items[1]->value) { |
|
67 case 'XYZ': |
|
68 require_once 'Zend/Pdf/Destination/Zoom.php'; |
|
69 return new Zend_Pdf_Destination_Zoom($resource); |
|
70 break; |
|
71 |
|
72 case 'Fit': |
|
73 require_once 'Zend/Pdf/Destination/Fit.php'; |
|
74 return new Zend_Pdf_Destination_Fit($resource); |
|
75 break; |
|
76 |
|
77 case 'FitH': |
|
78 require_once 'Zend/Pdf/Destination/FitHorizontally.php'; |
|
79 return new Zend_Pdf_Destination_FitHorizontally($resource); |
|
80 break; |
|
81 |
|
82 case 'FitV': |
|
83 require_once 'Zend/Pdf/Destination/FitVertically.php'; |
|
84 return new Zend_Pdf_Destination_FitVertically($resource); |
|
85 break; |
|
86 |
|
87 case 'FitR': |
|
88 require_once 'Zend/Pdf/Destination/FitRectangle.php'; |
|
89 return new Zend_Pdf_Destination_FitRectangle($resource); |
|
90 break; |
|
91 |
|
92 case 'FitB': |
|
93 require_once 'Zend/Pdf/Destination/FitBoundingBox.php'; |
|
94 return new Zend_Pdf_Destination_FitBoundingBox($resource); |
|
95 break; |
|
96 |
|
97 case 'FitBH': |
|
98 require_once 'Zend/Pdf/Destination/FitBoundingBoxHorizontally.php'; |
|
99 return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($resource); |
|
100 break; |
|
101 |
|
102 case 'FitBV': |
|
103 require_once 'Zend/Pdf/Destination/FitBoundingBoxVertically.php'; |
|
104 return new Zend_Pdf_Destination_FitBoundingBoxVertically($resource); |
|
105 break; |
|
106 |
|
107 default: |
|
108 require_once 'Zend/Pdf/Destination/Unknown.php'; |
|
109 return new Zend_Pdf_Destination_Unknown($resource); |
|
110 break; |
|
111 } |
|
112 } |
|
113 } |