File indexing completed on 2025-01-19 05:21:24
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 Actions 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 /** 0025 * PDF target (action or destination) 0026 * 0027 * @package Zend_Pdf 0028 * @subpackage Actions 0029 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0030 * @license http://framework.zend.com/license/new-bsd New BSD License 0031 */ 0032 abstract class Zend_Pdf_Target 0033 { 0034 /** 0035 * Parse resource and return it as an Action or Explicit Destination 0036 * 0037 * $param Zend_Pdf_Element $resource 0038 * @return Zend_Pdf_Destination| 0039 * @throws Zend_Pdf_Exception 0040 */ 0041 public static function load(Zend_Pdf_Element $resource) { 0042 // require_once 'Zend/Pdf/Element.php'; 0043 if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) { 0044 if (($resource->Type === null || $resource->Type->value =='Action') && $resource->S !== null) { 0045 // It's a well-formed action, load it 0046 // require_once 'Zend/Pdf/Action.php'; 0047 return Zend_Pdf_Action::load($resource); 0048 } else if ($resource->D !== null) { 0049 // It's a destination 0050 $resource = $resource->D; 0051 } else { 0052 // require_once 'Zend/Pdf/Exception.php'; 0053 throw new Zend_Pdf_Exception('Wrong resource type.'); 0054 } 0055 } 0056 0057 if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY || 0058 $resource->getType() == Zend_Pdf_Element::TYPE_NAME || 0059 $resource->getType() == Zend_Pdf_Element::TYPE_STRING) { 0060 // Resource is an array, just treat it as an explicit destination array 0061 // require_once 'Zend/Pdf/Destination.php'; 0062 return Zend_Pdf_Destination::load($resource); 0063 } else { 0064 // require_once 'Zend/Pdf/Exception.php'; 0065 throw new Zend_Pdf_Exception( 'Wrong resource type.' ); 0066 } 0067 } 0068 0069 /** 0070 * Get resource 0071 * 0072 * @internal 0073 * @return Zend_Pdf_Element 0074 */ 0075 abstract public function getResource(); 0076 }