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.

171 lines
5.1 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. * @subpackage Destination
  18. * @copyright Copyright (c) 2005-2014 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. /** Internally used classes */
  23. // require_once 'Zend/Pdf/Element/Array.php';
  24. // require_once 'Zend/Pdf/Element/Name.php';
  25. // require_once 'Zend/Pdf/Element/Numeric.php';
  26. /** Zend_Pdf_Destination_Explicit */
  27. // require_once 'Zend/Pdf/Destination/Explicit.php';
  28. /**
  29. * Zend_Pdf_Destination_FitRectangle explicit detination
  30. *
  31. * Destination array: [page /FitR left bottom right top]
  32. *
  33. * Display the page designated by page, with its contents magnified just enough
  34. * to fit the rectangle specified by the coordinates left, bottom, right, and top
  35. * entirely within the window both horizontally and vertically. If the required
  36. * horizontal and vertical magnification factors are different, use the smaller of
  37. * the two, centering the rectangle within the window in the other dimension.
  38. *
  39. * @package Zend_Pdf
  40. * @subpackage Destination
  41. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  42. * @license http://framework.zend.com/license/new-bsd New BSD License
  43. */
  44. class Zend_Pdf_Destination_FitRectangle extends Zend_Pdf_Destination_Explicit
  45. {
  46. /**
  47. * Create destination object
  48. *
  49. * @param Zend_Pdf_Page|integer $page Page object or page number
  50. * @param float $left Left edge of displayed page
  51. * @param float $bottom Bottom edge of displayed page
  52. * @param float $right Right edge of displayed page
  53. * @param float $top Top edge of displayed page
  54. * @return Zend_Pdf_Destination_FitRectangle
  55. * @throws Zend_Pdf_Exception
  56. */
  57. public static function create($page, $left, $bottom, $right, $top)
  58. {
  59. $destinationArray = new Zend_Pdf_Element_Array();
  60. 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 or a page number.');
  67. }
  68. $destinationArray->items[] = new Zend_Pdf_Element_Name('FitR');
  69. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
  70. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($bottom);
  71. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($right);
  72. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
  73. return new Zend_Pdf_Destination_FitRectangle($destinationArray);
  74. }
  75. /**
  76. * Get left edge of the displayed page
  77. *
  78. * @return float
  79. */
  80. public function getLeftEdge()
  81. {
  82. return $this->_destinationArray->items[2]->value;
  83. }
  84. /**
  85. * Set left edge of the displayed page
  86. *
  87. * @param float $left
  88. * @return Zend_Pdf_Action_FitRectangle
  89. */
  90. public function setLeftEdge($left)
  91. {
  92. $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
  93. return $this;
  94. }
  95. /**
  96. * Get bottom edge of the displayed page
  97. *
  98. * @return float
  99. */
  100. public function getBottomEdge()
  101. {
  102. return $this->_destinationArray->items[3]->value;
  103. }
  104. /**
  105. * Set bottom edge of the displayed page
  106. *
  107. * @param float $bottom
  108. * @return Zend_Pdf_Action_FitRectangle
  109. */
  110. public function setBottomEdge($bottom)
  111. {
  112. $this->_destinationArray->items[3] = new Zend_Pdf_Element_Numeric($bottom);
  113. return $this;
  114. }
  115. /**
  116. * Get right edge of the displayed page
  117. *
  118. * @return float
  119. */
  120. public function getRightEdge()
  121. {
  122. return $this->_destinationArray->items[4]->value;
  123. }
  124. /**
  125. * Set right edge of the displayed page
  126. *
  127. * @param float $right
  128. * @return Zend_Pdf_Action_FitRectangle
  129. */
  130. public function setRightEdge($right)
  131. {
  132. $this->_destinationArray->items[4] = new Zend_Pdf_Element_Numeric($right);
  133. return $this;
  134. }
  135. /**
  136. * Get top edge of the displayed page
  137. *
  138. * @return float
  139. */
  140. public function getTopEdge()
  141. {
  142. return $this->_destinationArray->items[5]->value;
  143. }
  144. /**
  145. * Set top edge of the displayed page
  146. *
  147. * @param float $top
  148. * @return Zend_Pdf_Action_FitRectangle
  149. */
  150. public function setTopEdge($top)
  151. {
  152. $this->_destinationArray->items[5] = new Zend_Pdf_Element_Numeric($top);
  153. return $this;
  154. }
  155. }