FitVertically.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 /FitV left]
  26. *
  27. * Display the page designated by page, with the horizontal coordinate left positioned
  28. * at the left edge of the window and the contents of the page magnified
  29. * just enough to fit the entire height of the page within the window.
  30. *
  31. * @package Zend_Pdf
  32. * @subpackage Destination
  33. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Pdf_Destination_FitVertically extends Zend_Pdf_Destination
  37. {
  38. /**
  39. * Create destination object
  40. *
  41. * @param Zend_Pdf_Page|Zend_Pdf_Element|integer $page Page object,
  42. * page number (integer or Zend_Pdf_Element_Numeric object) or
  43. * page dictionary object
  44. * @param float $left Left edge of displayed page
  45. * @return Zend_Pdf_Destination_FitVertically
  46. * @throws Zend_Pdf_Exception
  47. */
  48. public static function create($page, $left)
  49. {
  50. $destinationArray = new Zend_Pdf_Element_Array();
  51. if ($page instanceof Zend_Pdf_Element) {
  52. if ($page->getType() == Zend_Pdf_Element::TYPE_NUMERIC || $page->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
  53. // Page destination entry is a page number or page dictionary object
  54. $destinationArray->items[] = $page;
  55. } else {
  56. require_once 'Zend/Pdf/Exception.php';
  57. throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object, page number or page dictionary reference.');
  58. }
  59. } else if ($page instanceof Zend_Pdf_Page) {
  60. $destinationArray->items[] = $page->getPageDictionary();
  61. } else if (is_integer($page)) {
  62. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
  63. } else {
  64. require_once 'Zend/Pdf/Exception.php';
  65. throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object, page number or page dictionary reference.');
  66. }
  67. $destinationArray->items[] = new Zend_Pdf_Element_Name('FitV');
  68. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
  69. return new Zend_Pdf_Destination_FitVertically($destinationArray);
  70. }
  71. /**
  72. * Get left edge of the displayed page
  73. *
  74. * @return float
  75. */
  76. public function getLeftEdge()
  77. {
  78. return $this->_destinationArray->items[2]->value;
  79. }
  80. /**
  81. * Set left edge of the displayed page
  82. *
  83. * @param float $left
  84. * @return Zend_Pdf_Action_FitVertically
  85. */
  86. public function setLeftEdge($left)
  87. {
  88. $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
  89. return $this;
  90. }
  91. }