Named.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /** Zend_Pdf_Destination */
  23. require_once 'Zend/Pdf/Destination.php';
  24. /**
  25. * Destination array: [page /Fit]
  26. *
  27. * Display the page designated by page, with its contents magnified just enough
  28. * to fit the entire page within the window both horizontally and vertically. If
  29. * the required horizontal and vertical magnification factors are different, use
  30. * the smaller of the two, centering the page within the window in the other
  31. * dimension.
  32. *
  33. * @package Zend_Pdf
  34. * @subpackage Destination
  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
  37. */
  38. class Zend_Pdf_Destination_Named extends Zend_Pdf_Destination
  39. {
  40. /**
  41. * Destination name
  42. *
  43. * @var Zend_Pdf_Element_Name|Zend_Pdf_Element_String
  44. */
  45. protected $_nameElement;
  46. /**
  47. * Named destination object constructor
  48. *
  49. * @param $resource
  50. * @throws Zend_Pdf_Exception
  51. */
  52. public function __construct(Zend_Pdf_Element $resource)
  53. {
  54. if ($resource->getType() != Zend_Pdf_Element::TYPE_NAME && $resource->getType() != Zend_Pdf_Element::TYPE_STRING) {
  55. require_once 'Zend/Pdf/Exception.php';
  56. throw new Zend_Pdf_Exception('Named destination resource must be a PDF name or a PDF string.');
  57. }
  58. $this->_nameElement = $resource;
  59. }
  60. /**
  61. * Create named destination object
  62. *
  63. * @param string $name
  64. * @return Zend_Pdf_Destination_Named
  65. */
  66. public static function create($name)
  67. {
  68. return new Zend_Pdf_Destination_Named(new Zend_Pdf_Element_String($name));
  69. }
  70. /**
  71. * Get name
  72. *
  73. * @return Zend_Pdf_Element
  74. */
  75. public function getName()
  76. {
  77. return $this->_nameElement->value;
  78. }
  79. /**
  80. * Get resource
  81. *
  82. * @internal
  83. * @return Zend_Pdf_Element
  84. */
  85. public function getResource()
  86. {
  87. return $this->_nameElement;
  88. }
  89. }