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.
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
23 /** Zend_Pdf_ElementFactory */
24 require_once 'Zend/Pdf/ElementFactory.php';
28 * PDF target (action or destination)
32 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
35 abstract class Zend_Pdf_Target
38 * Parse resource and return it as an Action or Explicit Destination
40 * $param Zend_Pdf_Element $resource
41 * @return Zend_Pdf_Destination|
42 * @throws Zend_Pdf_Exception
44 public static function load(Zend_Pdf_Element
$resource) {
45 if ($resource->getType() == Zend_Pdf_Element
::TYPE_DICTIONARY
) {
46 if (($resource->Type
=== null ||
$resource->Type
->value
=='Action') && $resource->S
!== null) {
47 // It's a well-formed action, load it
48 return Zend_Pdf_Action
::load($resource);
49 } else if ($resource->D
!== null) {
51 $resource = $resource->D
;
53 require_once 'Zend/Pdf/Exception.php';
54 throw new Zend_Pdf_Exception('Wrong resource type.');
58 if ($resource->getType() == Zend_Pdf_Element
::TYPE_ARRAY ||
59 $resource->getType() == Zend_Pdf_Element
::TYPE_NAME ||
60 $resource->getType() == Zend_Pdf_Element
::TYPE_STRING
) {
61 // Resource is an array, just treat it as an explicit destination array
62 return Zend_Pdf_Destination
::load($resource);
64 require_once 'Zend/Pdf/Exception.php';
65 throw new Zend_Pdf_Exception( 'Wrong resource type.' );
73 * @return Zend_Pdf_Element
75 abstract public function getResource();