示例#1
0
 /**
  * Named destination object constructor
  *
  * @param Zend_Pdf_Element $resource
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $resource)
 {
     if ($resource->getType() != Zend_Pdf_Element::TYPE_NAME && $resource->getType() != Zend_Pdf_Element::TYPE_STRING) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Named destination resource must be a PDF name or a PDF string.');
     }
     $this->_nameElement = $resource;
 }
 /**
  * Load Destination object from a specified resource
  *
  * @internal
  * @param Zend_Pdf_Element $resource
  * @return Zend_Pdf_Destination
  */
 public static function load(Zend_Pdf_Element $resource)
 {
     require_once 'Zend/Pdf/Element.php';
     if ($resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
         require_once 'Zend/Pdf/Destination/Named.php';
         return new Zend_Pdf_Destination_Named($resource);
     }
     if ($resource->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('An explicit destination must be a direct or an indirect array object.');
     }
     if (count($resource->items) < 2) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('An explicit destination array must contain at least two elements.');
     }
     switch ($resource->items[1]->value) {
         case 'XYZ':
             require_once 'Zend/Pdf/Destination/Zoom.php';
             return new Zend_Pdf_Destination_Zoom($resource);
             break;
         case 'Fit':
             require_once 'Zend/Pdf/Destination/Fit.php';
             return new Zend_Pdf_Destination_Fit($resource);
             break;
         case 'FitH':
             require_once 'Zend/Pdf/Destination/FitHorizontally.php';
             return new Zend_Pdf_Destination_FitHorizontally($resource);
             break;
         case 'FitV':
             require_once 'Zend/Pdf/Destination/FitVertically.php';
             return new Zend_Pdf_Destination_FitVertically($resource);
             break;
         case 'FitR':
             require_once 'Zend/Pdf/Destination/FitRectangle.php';
             return new Zend_Pdf_Destination_FitRectangle($resource);
             break;
         case 'FitB':
             require_once 'Zend/Pdf/Destination/FitBoundingBox.php';
             return new Zend_Pdf_Destination_FitBoundingBox($resource);
             break;
         case 'FitBH':
             require_once 'Zend/Pdf/Destination/FitBoundingBoxHorizontally.php';
             return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($resource);
             break;
         case 'FitBV':
             require_once 'Zend/Pdf/Destination/FitBoundingBoxVertically.php';
             return new Zend_Pdf_Destination_FitBoundingBoxVertically($resource);
             break;
         default:
             require_once 'Zend/Pdf/Destination/Unknown.php';
             return new Zend_Pdf_Destination_Unknown($resource);
             break;
     }
 }
示例#3
0
 /**
  * Object constructor
  *
  * @param Zend_Pdf_Element $rootDictionary root of name dictionary
  */
 public function __construct(Zend_Pdf_Element $rootDictionary)
 {
     if ($rootDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Name tree root must be a dictionary.');
     }
     $intermediateNodes = array();
     $leafNodes = array();
     if ($rootDictionary->Kids !== null) {
         $intermediateNodes[] = $rootDictionary;
     } else {
         $leafNodes[] = $rootDictionary;
     }
     while (count($intermediateNodes) != 0) {
         $newIntermediateNodes = array();
         foreach ($intermediateNodes as $node) {
             foreach ($node->Kids->items as $childNode) {
                 if ($childNode->Kids !== null) {
                     $newIntermediateNodes[] = $childNode;
                 } else {
                     $leafNodes[] = $childNode;
                 }
             }
         }
         $intermediateNodes = $newIntermediateNodes;
     }
     foreach ($leafNodes as $leafNode) {
         $destinationsCount = count($leafNode->Names->items) / 2;
         for ($count = 0; $count < $destinationsCount; $count++) {
             $this->_items[$leafNode->Names->items[$count * 2]->value] = $leafNode->Names->items[$count * 2 + 1];
         }
     }
 }
示例#4
0
 /**
  * Parse resource and return it as an Action or Explicit Destination
  *
  * $param Zend_Pdf_Element $resource
  * @return Zend_Pdf_Destination|
  * @throws Zend_Pdf_Exception
  */
 public static function load(Zend_Pdf_Element $resource)
 {
     require_once 'Zend/Pdf/Element.php';
     if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
         if (($resource->Type === null || $resource->Type->value == 'Action') && $resource->S !== null) {
             // It's a well-formed action, load it
             require_once 'Zend/Pdf/Action.php';
             return Zend_Pdf_Action::load($resource);
         } else {
             if ($resource->D !== null) {
                 // It's a destination
                 $resource = $resource->D;
             } else {
                 require_once 'Zend/Pdf/Exception.php';
                 throw new Zend_Pdf_Exception('Wrong resource type.');
             }
         }
     }
     if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY || $resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
         // Resource is an array, just treat it as an explicit destination array
         require_once 'Zend/Pdf/Destination.php';
         return Zend_Pdf_Destination::load($resource);
     } else {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Wrong resource type.');
     }
 }
示例#5
0
 /**
  * Explicit destination object constructor
  *
  * @param Zend_Pdf_Element $destinationArray
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $destinationArray)
 {
     if ($destinationArray->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Explicit destination resource Array must be a direct or an indirect array object.');
     }
     $this->_destinationArray = $destinationArray;
     switch (count($this->_destinationArray->items)) {
         case 0:
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Destination array must contain a page reference.');
             break;
         case 1:
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Destination array must contain a destination type name.');
             break;
         default:
             // Do nothing
             break;
     }
     switch ($this->_destinationArray->items[0]->getType()) {
         case Zend_Pdf_Element::TYPE_NUMERIC:
             $this->_isRemote = true;
             break;
         case Zend_Pdf_Element::TYPE_DICTIONARY:
             $this->_isRemote = false;
             break;
         default:
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Destination target must be a page number or page dictionary object.');
             break;
     }
 }
示例#6
0
 /**
  * Annotation object constructor
  *
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $annotationDictionary)
 {
     if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once PHP_LIBRARY_PATH . 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
     }
     if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME || $annotationDictionary->Subtype->value != 'FileAttachment') {
         require_once PHP_LIBRARY_PATH . 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Subtype => FileAttachment entry is requires');
     }
     parent::__construct($annotationDictionary);
 }
示例#7
0
 /**
  * Annotation object constructor
  *
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $annotationDictionary)
 {
     if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
     }
     if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME || !in_array($annotationDictionary->Subtype->value, array(self::SUBTYPE_HIGHLIGHT, self::SUBTYPE_UNDERLINE, self::SUBTYPE_SQUIGGLY, self::SUBTYPE_STRIKEOUT))) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Subtype => Markup entry is omitted or has wrong value.');
     }
     parent::__construct($annotationDictionary);
 }
示例#8
0
 /**
  * Annotation object constructor
  *
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $annotationDictionary)
 {
     if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         //$1 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
     }
     if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME || $annotationDictionary->Subtype->value != 'Link') {
         //$1 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Subtype => Link entry is requires');
     }
     parent::__construct($annotationDictionary);
 }
示例#9
0
 /**
  * Parse resource and return it as an Action or Explicit Destination
  *
  * $param Zend_Pdf_Element $resource
  * @return Zend_Pdf_Destination|
  * @throws Zend_Pdf_Exception
  */
 public static function load(Zend_Pdf_Element $resource)
 {
     if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
         // Load destination as appropriate action
         return Zend_Pdf_Action::load($resource);
     } else {
         if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY || $resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
             // Resource is an array, just treat it as an explicit destination array
             return Zend_Pdf_Destination::load($resource);
         } else {
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Wrong resource type.');
         }
     }
 }
示例#10
0
 /**
  * Return type of the element.
  *
  * @return integer
  */
 public function getType()
 {
     return $this->_value->getType();
 }
示例#11
0
 /**
  * Load PDF action object using specified dictionary
  *
  * @internal
  * @param Zend_Pdf_Element $dictionary (It's actually Dictionary or Dictionary Object or Reference to a Dictionary Object)
  * @param SplObjectStorage $processedActions  list of already processed action dictionaries, used to avoid cyclic references
  * @return Zend_Pdf_Action
  * @throws Zend_Pdf_Exception
  */
 public static function load(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions = null)
 {
     if ($processedActions === null) {
         $processedActions = new SplObjectStorage();
     }
     require_once 'Zend/Pdf/Element.php';
     if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('$dictionary mast be a direct or an indirect dictionary object.');
     }
     if (isset($dictionary->Type) && $dictionary->Type->value != 'Action') {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Action dictionary Type entry must be set to \'Action\'.');
     }
     if ($dictionary->S === null) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Action dictionary must contain S entry');
     }
     switch ($dictionary->S->value) {
         case 'GoTo':
             require_once 'Zend/Pdf/Action/GoTo.php';
             return new Zend_Pdf_Action_GoTo($dictionary, $processedActions);
             brake;
         case 'GoToR':
             require_once 'Zend/Pdf/Action/GoToR.php';
             return new Zend_Pdf_Action_GoToR($dictionary, $processedActions);
             brake;
         case 'GoToE':
             require_once 'Zend/Pdf/Action/GoToE.php';
             return new Zend_Pdf_Action_GoToE($dictionary, $processedActions);
             brake;
         case 'Launch':
             require_once 'Zend/Pdf/Action/Launch.php';
             return new Zend_Pdf_Action_Launch($dictionary, $processedActions);
             brake;
         case 'Thread':
             require_once 'Zend/Pdf/Action/Thread.php';
             return new Zend_Pdf_Action_Thread($dictionary, $processedActions);
             brake;
         case 'URI':
             require_once 'Zend/Pdf/Action/URI.php';
             return new Zend_Pdf_Action_URI($dictionary, $processedActions);
             brake;
         case 'Sound':
             require_once 'Zend/Pdf/Action/Sound.php';
             return new Zend_Pdf_Action_Sound($dictionary, $processedActions);
             brake;
         case 'Movie':
             require_once 'Zend/Pdf/Action/Movie.php';
             return new Zend_Pdf_Action_Movie($dictionary, $processedActions);
             brake;
         case 'Hide':
             require_once 'Zend/Pdf/Action/Hide.php';
             return new Zend_Pdf_Action_Hide($dictionary, $processedActions);
             brake;
         case 'Named':
             require_once 'Zend/Pdf/Action/Named.php';
             return new Zend_Pdf_Action_Named($dictionary, $processedActions);
             brake;
         case 'SubmitForm':
             require_once 'Zend/Pdf/Action/SubmitForm.php';
             return new Zend_Pdf_Action_SubmitForm($dictionary, $processedActions);
             brake;
         case 'ResetForm':
             require_once 'Zend/Pdf/Action/ResetForm.php';
             return new Zend_Pdf_Action_ResetForm($dictionary, $processedActions);
             brake;
         case 'ImportData':
             require_once 'Zend/Pdf/Action/ImportData.php';
             return new Zend_Pdf_Action_ImportData($dictionary, $processedActions);
             brake;
         case 'JavaScript':
             require_once 'Zend/Pdf/Action/JavaScript.php';
             return new Zend_Pdf_Action_JavaScript($dictionary, $processedActions);
             brake;
         case 'SetOCGState':
             require_once 'Zend/Pdf/Action/SetOCGState.php';
             return new Zend_Pdf_Action_SetOCGState($dictionary, $processedActions);
             brake;
         case 'Rendition':
             require_once 'Zend/Pdf/Action/Rendition.php';
             return new Zend_Pdf_Action_Rendition($dictionary, $processedActions);
             brake;
         case 'Trans':
             require_once 'Zend/Pdf/Action/Trans.php';
             return new Zend_Pdf_Action_Trans($dictionary, $processedActions);
             brake;
         case 'GoTo3DView':
             require_once 'Zend/Pdf/Action/GoTo3DView.php';
             return new Zend_Pdf_Action_GoTo3DView($dictionary, $processedActions);
             brake;
         default:
             require_once 'Zend/Pdf/Action/Unknown.php';
             return new Zend_Pdf_Action_Unknown($dictionary, $processedActions);
             brake;
     }
 }
示例#12
0
 /**
  * Annotation object constructor
  *
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $annotationDictionary)
 {
     if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
     }
     $this->_annotationDictionary = $annotationDictionary;
     if ($this->_annotationDictionary->Type !== null && $this->_annotationDictionary->Type->value != 'Annot') {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Wrong resource type. \'Annot\' expected.');
     }
     if ($this->_annotationDictionary->Rect === null) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('\'Rect\' dictionary entry is required.');
     }
     if (count($this->_annotationDictionary->Rect->items) != 4 || $this->_annotationDictionary->Rect->items[0]->getType() != Zend_Pdf_Element::TYPE_NUMERIC || $this->_annotationDictionary->Rect->items[1]->getType() != Zend_Pdf_Element::TYPE_NUMERIC || $this->_annotationDictionary->Rect->items[2]->getType() != Zend_Pdf_Element::TYPE_NUMERIC || $this->_annotationDictionary->Rect->items[3]->getType() != Zend_Pdf_Element::TYPE_NUMERIC) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('\'Rect\' dictionary entry must be an array of four numeric elements.');
     }
 }
示例#13
0
 /**
  * Create PDF outline object using specified dictionary
  *
  * @internal
  * @param Zend_Pdf_Element $dictionary (It's actually Dictionary or Dictionary Object or Reference to a Dictionary Object)
  * @param Zend_Pdf_Action  $parentAction
  * @param SplObjectStorage $processedOutlines  List of already processed Outline dictionaries,
  *                                             used to avoid cyclic references
  * @return Zend_Pdf_Action
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedDictionaries = null)
 {
     if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('$dictionary mast be an indirect dictionary object.');
     }
     if ($processedDictionaries === null) {
         $processedDictionaries = new SplObjectStorage();
     }
     $processedDictionaries->attach($dictionary);
     $this->_outlineDictionary = $dictionary;
     if ($dictionary->Count !== null) {
         if ($dictionary->Count->getType() != Zend_Pdf_Element::TYPE_NUMERIC) {
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Outline dictionary Count entry must be a numeric element.');
         }
         $childOutlinesCount = $dictionary->Count->value;
         if ($childOutlinesCount > 0) {
             $this->_open = true;
         }
         $childOutlinesCount = abs($childOutlinesCount);
         $childDictionary = $dictionary->First;
         $children = new SplObjectStorage();
         while ($childDictionary !== null) {
             // Check children structure for cyclic references
             if ($children->contains($childDictionary)) {
                 require_once 'Zend/Pdf/Exception.php';
                 throw new Zend_Pdf_Exception('Outline childs load error.');
             }
             if (!$processedDictionaries->contains($childDictionary)) {
                 $this->childOutlines[] = new Zend_Pdf_Outline_Loaded($childDictionary, $processedDictionaries);
             }
             $childDictionary = $childDictionary->Next;
         }
         $this->_originalChildOutlines = $this->childOutlines;
     }
 }