/** * Object constructor * * @param \ZendPdf\InternalType\DictionaryObject $dictionary * @param SplObjectStorage $processedActions list of already processed action dictionaries, * used to avoid cyclic references * @throws \ZendPdf\Exception\ExceptionInterface */ public function __construct(InternalType\AbstractTypeObject $dictionary, \SplObjectStorage $processedActions) { parent::__construct($dictionary, $processedActions); if ($dictionary->URI === null) { throw new Exception\CorruptedPdfException('URI action dictionary entry is required'); } }
/** * Parse resource and return it as an Action or Explicit Destination * * $param \ZendPdf\InternalType $resource * @return \ZendPdf\Destination\AbstractDestination|\ZendPdf\Action\AbstractAction * @throws \ZendPdf\Exception\ExceptionInterface */ public static function load(InternalType\AbstractTypeObject $resource) { if ($resource->getType() == InternalType\AbstractTypeObject::TYPE_DICTIONARY) { if (($resource->Type === null || $resource->Type->value == 'Action') && $resource->S !== null) { // It's a well-formed action, load it return Action\AbstractAction::load($resource); } elseif ($resource->D !== null) { // It's a destination $resource = $resource->D; } else { throw new Exception\CorruptedPdfException('Wrong resource type.'); } } if ($resource->getType() == InternalType\AbstractTypeObject::TYPE_ARRAY || $resource->getType() == InternalType\AbstractTypeObject::TYPE_NAME || $resource->getType() == InternalType\AbstractTypeObject::TYPE_STRING) { // Resource is an array, just treat it as an explicit destination array return Destination\AbstractDestination::load($resource); } else { throw new Exception\CorruptedPdfException('Wrong resource type.'); } }
/** * Get outline target. * * @return \ZendPdf\InternalStructure\NavigationTarget * @throws \ZendPdf\Exception\ExceptionInterface */ public function getTarget() { if ($this->_outlineDictionary->Dest !== null) { if ($this->_outlineDictionary->A !== null) { throw new Exception\CorruptedPdfException('Outline dictionary may contain Dest or A entry, but not both.'); } return Destination\AbstractDestination::load($this->_outlineDictionary->Dest); } elseif ($this->_outlineDictionary->A !== null) { return Action\AbstractAction::load($this->_outlineDictionary->A); } return null; }
public function testActionURILoad2() { $dictionary = new InternalType\DictionaryObject(); $dictionary->Type = new InternalType\NameObject('Action'); $dictionary->S = new InternalType\NameObject('URI'); $this->setExpectedException('\\ZendPdf\\Exception\\CorruptedPdfException', 'URI action dictionary entry is required'); $action = Action\AbstractAction::load($dictionary); }
/** * Object constructor * * @param \ZendPdf\InternalType\DictionaryObject $dictionary * @param SplObjectStorage $processedActions list of already processed action dictionaries, * used to avoid cyclic references */ public function __construct(InternalType\AbstractTypeObject $dictionary, \SplObjectStorage $processedActions) { parent::__construct($dictionary, $processedActions); $this->_destination = Destination\AbstractDestination::load($dictionary->D); }
/** * Get link annotation destination * * @return \ZendPdf\InternalStructure\NavigationTarget|null */ public function getDestination() { if ($this->_annotationDictionary->Dest === null && $this->_annotationDictionary->A === null) { return null; } if ($this->_annotationDictionary->Dest !== null) { return Destination\AbstractDestination::load($this->_annotationDictionary->Dest); } else { return Pdf\Action\AbstractAction::load($this->_annotationDictionary->A); } }