2
0

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