Destination.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.php';
  24. /** Zend_Pdf_Target */
  25. #require_once 'Zend/Pdf/Target.php';
  26. /**
  27. * Abstract PDF destination representation class
  28. *
  29. * @package Zend_Pdf
  30. * @subpackage Destination
  31. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. abstract class Zend_Pdf_Destination extends Zend_Pdf_Target
  35. {
  36. /**
  37. * Load Destination object from a specified resource
  38. *
  39. * @internal
  40. * @param Zend_Pdf_Element $resource
  41. * @return Zend_Pdf_Destination
  42. */
  43. public static function load(Zend_Pdf_Element $resource)
  44. {
  45. #require_once 'Zend/Pdf/Element.php';
  46. if ($resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
  47. #require_once 'Zend/Pdf/Destination/Named.php';
  48. return new Zend_Pdf_Destination_Named($resource);
  49. }
  50. if ($resource->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
  51. #require_once 'Zend/Pdf/Exception.php';
  52. throw new Zend_Pdf_Exception('An explicit destination must be a direct or an indirect array object.');
  53. }
  54. if (count($resource->items) < 2) {
  55. #require_once 'Zend/Pdf/Exception.php';
  56. throw new Zend_Pdf_Exception('An explicit destination array must contain at least two elements.');
  57. }
  58. switch ($resource->items[1]->value) {
  59. case 'XYZ':
  60. #require_once 'Zend/Pdf/Destination/Zoom.php';
  61. return new Zend_Pdf_Destination_Zoom($resource);
  62. break;
  63. case 'Fit':
  64. #require_once 'Zend/Pdf/Destination/Fit.php';
  65. return new Zend_Pdf_Destination_Fit($resource);
  66. break;
  67. case 'FitH':
  68. #require_once 'Zend/Pdf/Destination/FitHorizontally.php';
  69. return new Zend_Pdf_Destination_FitHorizontally($resource);
  70. break;
  71. case 'FitV':
  72. #require_once 'Zend/Pdf/Destination/FitVertically.php';
  73. return new Zend_Pdf_Destination_FitVertically($resource);
  74. break;
  75. case 'FitR':
  76. #require_once 'Zend/Pdf/Destination/FitRectangle.php';
  77. return new Zend_Pdf_Destination_FitRectangle($resource);
  78. break;
  79. case 'FitB':
  80. #require_once 'Zend/Pdf/Destination/FitBoundingBox.php';
  81. return new Zend_Pdf_Destination_FitBoundingBox($resource);
  82. break;
  83. case 'FitBH':
  84. #require_once 'Zend/Pdf/Destination/FitBoundingBoxHorizontally.php';
  85. return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($resource);
  86. break;
  87. case 'FitBV':
  88. #require_once 'Zend/Pdf/Destination/FitBoundingBoxVertically.php';
  89. return new Zend_Pdf_Destination_FitBoundingBoxVertically($resource);
  90. break;
  91. default:
  92. #require_once 'Zend/Pdf/Destination/Unknown.php';
  93. return new Zend_Pdf_Destination_Unknown($resource);
  94. break;
  95. }
  96. }
  97. }