You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.9 KiB

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