2
0

FitBoundingBox.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_FitBoundingBox explicit detination
  26. *
  27. * Destination array: [page /FitB]
  28. *
  29. * (PDF 1.1) Display the page designated by page, with its contents magnified
  30. * just enough to fit its bounding box entirely within the window both horizontally
  31. * and vertically. If the required horizontal and vertical magnification
  32. * factors are different, use the smaller of the two, centering the bounding box
  33. * within the window in the other dimension.
  34. *
  35. * @package Zend_Pdf
  36. * @subpackage Destination
  37. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Pdf_Destination_FitBoundingBox extends Zend_Pdf_Destination_Explicit
  41. {
  42. /**
  43. * Create destination object
  44. *
  45. * @param Zend_Pdf_Page|integer $page Page object or page number
  46. * @return Zend_Pdf_Destination_FitBoundingBox
  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_Page) {
  53. $destinationArray->items[] = $page->getPageDictionary();
  54. } else if (is_integer($page)) {
  55. $destinationArray->items[] = new Zend_Pdf_Element_Numeric($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 or a page number.');
  59. }
  60. $destinationArray->items[] = new Zend_Pdf_Element_Name('FitB');
  61. return new Zend_Pdf_Destination_FitBoundingBox($destinationArray);
  62. }
  63. }