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.
17 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 * @version $Id: Object.php 17182 2009-07-27 13:54:11Z alexander $
23 /** Zend_Pdf_Element */
24 require_once 'Zend/Pdf/Element.php';
26 /** Zend_Pdf_ElementFactory */
27 require_once 'Zend/Pdf/ElementFactory.php';
31 * PDF file 'indirect object' element implementation
35 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Pdf_Element_Object
extends Zend_Pdf_Element
43 * @var Zend_Pdf_Element
48 * Object number within PDF file
62 * Reference to the factory.
64 * @var Zend_Pdf_ElementFactory
71 * @param Zend_Pdf_Element $val
72 * @param integer $objNum
73 * @param integer $genNum
74 * @param Zend_Pdf_ElementFactory $factory
75 * @throws Zend_Pdf_Exception
77 public function __construct(Zend_Pdf_Element
$val, $objNum, $genNum, Zend_Pdf_ElementFactory
$factory)
79 if ($val instanceof self
) {
80 throw new Zend_Pdf_Exception('Object number must not be an instance of Zend_Pdf_Element_Object.');
83 if ( !(is_integer($objNum) && $objNum > 0) ) {
84 throw new Zend_Pdf_Exception('Object number must be positive integer.');
87 if ( !(is_integer($genNum) && $genNum >= 0) ) {
88 throw new Zend_Pdf_Exception('Generation number must be non-negative integer.');
92 $this->_objNum
= $objNum;
93 $this->_genNum
= $genNum;
94 $this->_factory
= $factory;
96 $this->setParentObject($this);
98 $factory->registerObject($this, $objNum . ' ' . $genNum);
103 * Check, that object is generated by specified factory
105 * @return Zend_Pdf_ElementFactory
107 public function getFactory()
109 return $this->_factory
;
113 * Return type of the element.
117 public function getType()
119 return $this->_value
->getType();
128 public function getObjNum()
130 return $this->_objNum
;
135 * Get generation number
139 public function getGenNum()
141 return $this->_genNum
;
146 * Return reference to the object
148 * @param Zend_Pdf_Factory $factory
151 public function toString($factory = null)
153 if ($factory === null) {
156 $shift = $factory->getEnumerationShift($this->_factory
);
159 return $this->_objNum +
$shift . ' ' . $this->_genNum
. ' R';
164 * Dump object to a string to save within PDF file.
166 * $factory parameter defines operation context.
168 * @param Zend_Pdf_ElementFactory $factory
171 public function dump(Zend_Pdf_ElementFactory
$factory)
173 $shift = $factory->getEnumerationShift($this->_factory
);
175 return $this->_objNum +
$shift . " " . $this->_genNum
. " obj \n"
176 . $this->_value
->toString($factory) . "\n"
183 * @param string $property
186 public function __get($property)
188 return $this->_value
->$property;
194 * @param string $property
195 * @param mixed $value
197 public function __set($property, $value)
199 $this->_value
->$property = $value;
205 * @param string $method
209 public function __call($method, $args)
211 return call_user_func_array(array($this->_value
, $method), $args);
216 * Mark object as modified, to include it into new PDF file segment
218 public function touch()
220 $this->_factory
->markAsModified($this);
224 * Return object, which can be used to identify object and its references identity
226 * @return Zend_Pdf_Element_Object
228 public function getObject()
234 * Clean up resources, used by object
236 public function cleanUp()
238 $this->_value
= null;
242 * Convert PDF element to PHP type.
246 public function toPhp()
248 return $this->_value
->toPhp();