FitBoundingBoxVertically.php 3.6 KB

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