You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.0 KiB

11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
  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. }