File indexing completed on 2024-05-12 06:02:53

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Pdf
0017  * @subpackage Destination
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 
0024 /** Internally used classes */
0025 // require_once 'Zend/Pdf/Element.php';
0026 
0027 
0028 /** Zend_Pdf_Target */
0029 // require_once 'Zend/Pdf/Target.php';
0030 
0031 
0032 /**
0033  * Abstract PDF destination representation class
0034  *
0035  * @package    Zend_Pdf
0036  * @subpackage Destination
0037  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0038  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0039  */
0040 abstract class Zend_Pdf_Destination extends Zend_Pdf_Target
0041 {
0042     /**
0043      * Load Destination object from a specified resource
0044      *
0045      * @internal
0046      * @param Zend_Pdf_Element $resource
0047      * @return Zend_Pdf_Destination
0048      */
0049     public static function load(Zend_Pdf_Element $resource)
0050     {
0051         // require_once 'Zend/Pdf/Element.php';
0052         if ($resource->getType() == Zend_Pdf_Element::TYPE_NAME  ||  $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
0053             // require_once 'Zend/Pdf/Destination/Named.php';
0054             return new Zend_Pdf_Destination_Named($resource);
0055         }
0056 
0057         if ($resource->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
0058             // require_once 'Zend/Pdf/Exception.php';
0059             throw new Zend_Pdf_Exception('An explicit destination must be a direct or an indirect array object.');
0060         }
0061         if (count($resource->items) < 2) {
0062             // require_once 'Zend/Pdf/Exception.php';
0063             throw new Zend_Pdf_Exception('An explicit destination array must contain at least two elements.');
0064         }
0065 
0066         switch ($resource->items[1]->value) {
0067             case 'XYZ':
0068                 // require_once 'Zend/Pdf/Destination/Zoom.php';
0069                 return new Zend_Pdf_Destination_Zoom($resource);
0070                 break;
0071 
0072             case 'Fit':
0073                 // require_once 'Zend/Pdf/Destination/Fit.php';
0074                 return new Zend_Pdf_Destination_Fit($resource);
0075                 break;
0076 
0077             case 'FitH':
0078                 // require_once 'Zend/Pdf/Destination/FitHorizontally.php';
0079                 return new Zend_Pdf_Destination_FitHorizontally($resource);
0080                 break;
0081 
0082             case 'FitV':
0083                 // require_once 'Zend/Pdf/Destination/FitVertically.php';
0084                 return new Zend_Pdf_Destination_FitVertically($resource);
0085                 break;
0086 
0087             case 'FitR':
0088                 // require_once 'Zend/Pdf/Destination/FitRectangle.php';
0089                 return new Zend_Pdf_Destination_FitRectangle($resource);
0090                 break;
0091 
0092             case 'FitB':
0093                 // require_once 'Zend/Pdf/Destination/FitBoundingBox.php';
0094                 return new Zend_Pdf_Destination_FitBoundingBox($resource);
0095                 break;
0096 
0097             case 'FitBH':
0098                 // require_once 'Zend/Pdf/Destination/FitBoundingBoxHorizontally.php';
0099                 return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($resource);
0100                 break;
0101 
0102             case 'FitBV':
0103                 // require_once 'Zend/Pdf/Destination/FitBoundingBoxVertically.php';
0104                 return new Zend_Pdf_Destination_FitBoundingBoxVertically($resource);
0105                 break;
0106 
0107             default:
0108                 // require_once 'Zend/Pdf/Destination/Unknown.php';
0109                 return new Zend_Pdf_Destination_Unknown($resource);
0110                 break;
0111         }
0112     }
0113 }