Fit.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 /Fit]
  26. *
  27. * Display the page designated by page, with its contents magnified just enough
  28. * to fit the entire page within the window both horizontally and vertically. If
  29. * the required horizontal and vertical magnification factors are different, use
  30. * the smaller of the two, centering the page within the window in the other
  31. * dimension.
  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_Fit extends Zend_Pdf_Destination
  39. {
  40. /**
  41. * Create destination object
  42. *
  43. * @param Zend_Pdf_Page|Zend_Pdf_Element|integer $page Page object,
  44. * page number (integer or Zend_Pdf_Element_Numeric object) or
  45. * page dictionary object
  46. * @return Zend_Pdf_Destination_Fit
  47. * @throws Zend_Pdf_Exception
  48. */
  49. public static function create($page)
  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('Fit');
  69. return new Zend_Pdf_Destination_Fit($destinationArray);
  70. }
  71. }