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.

98 lines
3.1 KiB

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