File indexing completed on 2025-01-19 05:21:24
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Pdf 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 0023 /** 0024 * PDF file trailer 0025 * 0026 * @package Zend_Pdf 0027 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0028 * @license http://framework.zend.com/license/new-bsd New BSD License 0029 */ 0030 abstract class Zend_Pdf_Trailer 0031 { 0032 private static $_allowedKeys = array('Size', 'Prev', 'Root', 'Encrypt', 'Info', 'ID', 'Index', 'W', 'XRefStm', 'DocChecksum'); 0033 0034 /** 0035 * Trailer dictionary. 0036 * 0037 * @var Zend_Pdf_Element_Dictionary 0038 */ 0039 private $_dict; 0040 0041 /** 0042 * Check if key is correct 0043 * 0044 * @param string $key 0045 * @throws Zend_Pdf_Exception 0046 */ 0047 private function _checkDictKey($key) 0048 { 0049 if ( !in_array($key, self::$_allowedKeys) ) { 0050 /** @todo Make warning (log entry) instead of an exception */ 0051 // require_once 'Zend/Pdf/Exception.php'; 0052 throw new Zend_Pdf_Exception("Unknown trailer dictionary key: '$key'."); 0053 } 0054 } 0055 0056 0057 /** 0058 * Object constructor 0059 * 0060 * @param Zend_Pdf_Element_Dictionary $dict 0061 */ 0062 public function __construct(Zend_Pdf_Element_Dictionary $dict) 0063 { 0064 $this->_dict = $dict; 0065 0066 foreach ($this->_dict->getKeys() as $dictKey) { 0067 $this->_checkDictKey($dictKey); 0068 } 0069 } 0070 0071 /** 0072 * Get handler 0073 * 0074 * @param string $property 0075 * @return mixed 0076 */ 0077 public function __get($property) 0078 { 0079 return $this->_dict->$property; 0080 } 0081 0082 /** 0083 * Set handler 0084 * 0085 * @param string $property 0086 * @param mixed $value 0087 */ 0088 public function __set($property, $value) 0089 { 0090 $this->_checkDictKey($property); 0091 $this->_dict->$property = $value; 0092 } 0093 0094 /** 0095 * Return string trailer representation 0096 * 0097 * @return string 0098 */ 0099 public function toString() 0100 { 0101 return "trailer\n" . $this->_dict->toString() . "\n"; 0102 } 0103 0104 0105 /** 0106 * Get length of source PDF 0107 * 0108 * @return string 0109 */ 0110 abstract public function getPDFLength(); 0111 0112 /** 0113 * Get PDF String 0114 * 0115 * @return string 0116 */ 0117 abstract public function getPDFString(); 0118 0119 /** 0120 * Get header of free objects list 0121 * Returns object number of last free object 0122 * 0123 * @return integer 0124 */ 0125 abstract public function getLastFreeObject(); 0126 }