|
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 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
19 * @version $Id: Trailer.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
20 */ |
|
21 |
|
22 |
|
23 /** |
|
24 * PDF file trailer |
|
25 * |
|
26 * @package Zend_Pdf |
|
27 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
29 */ |
|
30 abstract class Zend_Pdf_Trailer |
|
31 { |
|
32 private static $_allowedKeys = array('Size', 'Prev', 'Root', 'Encrypt', 'Info', 'ID', 'Index', 'W', 'XRefStm', 'DocChecksum'); |
|
33 |
|
34 /** |
|
35 * Trailer dictionary. |
|
36 * |
|
37 * @var Zend_Pdf_Element_Dictionary |
|
38 */ |
|
39 private $_dict; |
|
40 |
|
41 /** |
|
42 * Check if key is correct |
|
43 * |
|
44 * @param string $key |
|
45 * @throws Zend_Pdf_Exception |
|
46 */ |
|
47 private function _checkDictKey($key) |
|
48 { |
|
49 if ( !in_array($key, self::$_allowedKeys) ) { |
|
50 /** @todo Make warning (log entry) instead of an exception */ |
|
51 require_once 'Zend/Pdf/Exception.php'; |
|
52 throw new Zend_Pdf_Exception("Unknown trailer dictionary key: '$key'."); |
|
53 } |
|
54 } |
|
55 |
|
56 |
|
57 /** |
|
58 * Object constructor |
|
59 * |
|
60 * @param Zend_Pdf_Element_Dictionary $dict |
|
61 */ |
|
62 public function __construct(Zend_Pdf_Element_Dictionary $dict) |
|
63 { |
|
64 $this->_dict = $dict; |
|
65 |
|
66 foreach ($this->_dict->getKeys() as $dictKey) { |
|
67 $this->_checkDictKey($dictKey); |
|
68 } |
|
69 } |
|
70 |
|
71 /** |
|
72 * Get handler |
|
73 * |
|
74 * @param string $property |
|
75 * @return mixed |
|
76 */ |
|
77 public function __get($property) |
|
78 { |
|
79 return $this->_dict->$property; |
|
80 } |
|
81 |
|
82 /** |
|
83 * Set handler |
|
84 * |
|
85 * @param string $property |
|
86 * @param mixed $value |
|
87 */ |
|
88 public function __set($property, $value) |
|
89 { |
|
90 $this->_checkDictKey($property); |
|
91 $this->_dict->$property = $value; |
|
92 } |
|
93 |
|
94 /** |
|
95 * Return string trailer representation |
|
96 * |
|
97 * @return string |
|
98 */ |
|
99 public function toString() |
|
100 { |
|
101 return "trailer\n" . $this->_dict->toString() . "\n"; |
|
102 } |
|
103 |
|
104 |
|
105 /** |
|
106 * Get length of source PDF |
|
107 * |
|
108 * @return string |
|
109 */ |
|
110 abstract public function getPDFLength(); |
|
111 |
|
112 /** |
|
113 * Get PDF String |
|
114 * |
|
115 * @return string |
|
116 */ |
|
117 abstract public function getPDFString(); |
|
118 |
|
119 /** |
|
120 * Get header of free objects list |
|
121 * Returns object number of last free object |
|
122 * |
|
123 * @return integer |
|
124 */ |
|
125 abstract public function getLastFreeObject(); |
|
126 } |