FitVertically.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_Explicit */
  23. require_once 'Zend/Pdf/Destination/Explicit.php';
  24. /**
  25. * Zend_Pdf_Destination_FitVertically explicit detination
  26. *
  27. * Destination array: [page /FitV left]
  28. *
  29. * Display the page designated by page, with the horizontal coordinate left positioned
  30. * at the left edge of the window and the contents of the page magnified
  31. * just enough to fit the entire height of the page within the window.
  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_FitVertically extends Zend_Pdf_Destination_Explicit
  39. {
  40. /**
  41. * Create destination object
  42. *
  43. * @param Zend_Pdf_Page|integer $page Page object or page number
  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_Page) {
  52. $destinationArray->items[] = $page->getPageDictionary();
  53. } else if (is_integer($page)) {
  54. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($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 or page number.');
  58. }
  59. $destinationArray->items[] = new Zend_Pdf_Element_Name('FitV');
  60. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
  61. return new Zend_Pdf_Destination_FitVertically($destinationArray);
  62. }
  63. /**
  64. * Get left edge of the displayed page
  65. *
  66. * @return float
  67. */
  68. public function getLeftEdge()
  69. {
  70. return $this->_destinationArray->items[2]->value;
  71. }
  72. /**
  73. * Set left edge of the displayed page
  74. *
  75. * @param float $left
  76. * @return Zend_Pdf_Action_FitVertically
  77. */
  78. public function setLeftEdge($left)
  79. {
  80. $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
  81. return $this;
  82. }
  83. }