php Zend-Pdf-InternalType-AbstractTypeObject类(方法)实例源码

下面列出了php Zend-Pdf-InternalType-AbstractTypeObject 类(方法)源码代码实例,从而了解它的用法。

作者:alab100110    项目:zf   
/**
  * Explicit destination object constructor
  *
  * @param \Zend\Pdf\InternalType\AbstractTypeObject $destinationArray
  * @throws \Zend\Pdf\Exception
  */
 public function __construct(InternalType\AbstractTypeObject $destinationArray)
 {
     if ($destinationArray->getType() != InternalType\AbstractTypeObject::TYPE_ARRAY) {
         throw new Exception\CorruptedPdfException('Explicit destination resource Array must be a direct or an indirect array object.');
     }
     $this->_destinationArray = $destinationArray;
     switch (count($this->_destinationArray->items)) {
         case 0:
             throw new Exception\CorruptedPdfException('Destination array must contain a page reference.');
             break;
         case 1:
             throw new Exception\CorruptedPdfException('Destination array must contain a destination type name.');
             break;
         default:
             // Do nothing
             break;
     }
     switch ($this->_destinationArray->items[0]->getType()) {
         case InternalType\AbstractTypeObject::TYPE_NUMERIC:
             $this->_isRemote = true;
             break;
         case InternalType\AbstractTypeObject::TYPE_DICTIONARY:
             $this->_isRemote = false;
             break;
         default:
             throw new Exception\CorruptedPdfException('Destination target must be a page number or page dictionary object.');
             break;
     }
 }

作者:rexma    项目:zf   
/**
  * Object constructor
  *
  * @param $rootDictionary root of name dictionary
  * @throws \Zend\Pdf\Exception
  */
 public function __construct(InternalType\AbstractTypeObject $rootDictionary)
 {
     if ($rootDictionary->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) {
         throw new Exception\CorruptedPdfException('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];
         }
     }
 }

作者:bradley-hol    项目:zf   
/**
  * Named destination object constructor
  *
  * @param $resource
  * @throws \Zend\Pdf\Exception
  */
 public function __construct(InternalType\AbstractTypeObject $resource)
 {
     if ($resource->getType() != InternalType\AbstractTypeObject::TYPE_NAME && $resource->getType() != InternalType\AbstractTypeObject::TYPE_STRING) {
         throw new Exception\CorruptedPdfException('Named destination resource must be a PDF name or a PDF string.');
     }
     $this->_nameElement = $resource;
 }

作者:robertodormepoc    项目:zf   
/**
  * Annotation object constructor
  *
  * @throws \Zend\Pdf\Exception\ExceptionInterface
  */
 public function __construct(InternalType\AbstractTypeObject $annotationDictionary)
 {
     if ($annotationDictionary->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) {
         throw new Exception\CorruptedPdfException('Annotation dictionary resource has to be a dictionary.');
     }
     if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != InternalType\AbstractTypeObject::TYPE_NAME || $annotationDictionary->Subtype->value != 'Link') {
         throw new Exception\CorruptedPdfException('Subtype => Link entry is requires');
     }
     parent::__construct($annotationDictionary);
 }

作者:alab100110    项目:zf   
/**
  * Annotation object constructor
  *
  * @throws \Zend\Pdf\Exception
  */
 public function __construct(InternalType\AbstractTypeObject $annotationDictionary)
 {
     if ($annotationDictionary->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) {
         throw new Exception\CorruptedPdfException('Annotation dictionary resource has to be a dictionary.');
     }
     if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != InternalType\AbstractTypeObject::TYPE_NAME || !in_array($annotationDictionary->Subtype->value, array(self::SUBTYPE_HIGHLIGHT, self::SUBTYPE_UNDERLINE, self::SUBTYPE_SQUIGGLY, self::SUBTYPE_STRIKEOUT))) {
         throw new Exception\CorruptedPdfException('Subtype => Markup entry is omitted or has wrong value.');
     }
     parent::__construct($annotationDictionary);
 }

作者:niallmccrudde    项目:zf   
/**
     * Load Destination object from a specified resource
     *
     * @internal
     * @param $destinationArray
     * @return \Zend\Pdf\Destination\AbstractDestination
     */
    public static function load(InternalType\AbstractTypeObject $resource)
    {
        if ($resource->getType() == InternalType\AbstractTypeObject::TYPE_NAME  ||  $resource->getType() == InternalType\AbstractTypeObject::TYPE_STRING) {
            return new Named($resource);
        }

        if ($resource->getType() != InternalType\AbstractTypeObject::TYPE_ARRAY) {
            throw new Exception\CorruptedPdfException('An explicit destination must be a direct or an indirect array object.');
        }
        if (count($resource->items) < 2) {
            throw new Exception\CorruptedPdfException('An explicit destination array must contain at least two elements.');
        }

        switch ($resource->items[1]->value) {
            case 'XYZ':
                return new Zoom($resource);
                break;

            case 'Fit':
                return new Fit($resource);
                break;

            case 'FitH':
                return new FitHorizontally($resource);
                break;

            case 'FitV':
                return new FitVertically($resource);
                break;

            case 'FitR':
                return new FitRectangle($resource);
                break;

            case 'FitB':
                return new FitBoundingBox($resource);
                break;

            case 'FitBH':
                return new FitBoundingBoxHorizontally($resource);
                break;

            case 'FitBV':
                return new FitBoundingBoxVertically($resource);
                break;

            default:
                return new Unknown($resource);
                break;
        }
    }

作者:robertodormepoc    项目:zf   
/**
  * Parse resource and return it as an Action or Explicit Destination
  *
  * $param \Zend\Pdf\InternalType $resource
  * @return \Zend\Pdf\Destination\AbstractDestination|\Zend\Pdf\Action\AbstractAction
  * @throws \Zend\Pdf\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.');
     }
 }

作者:stunt    项目:zf   
/**
  * Load PDF action object using specified dictionary
  *
  * @internal
  * @param \Zend\PDF\InternalType\AbstractTypeObject $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\AbstractAction
  * @throws \Zend\PDF\Exception
  */
 public static function load(InternalType\AbstractTypeObject $dictionary, \SplObjectStorage $processedActions = null)
 {
     if ($processedActions === null) {
         $processedActions = new \SplObjectStorage();
     }
     if ($dictionary->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) {
         throw new PDF\Exception('$dictionary mast be a direct or an indirect dictionary object.');
     }
     if (isset($dictionary->Type) && $dictionary->Type->value != 'Action') {
         throw new PDF\Exception('Action dictionary Type entry must be set to \'Action\'.');
     }
     if ($dictionary->S === null) {
         throw new PDF\Exception('Action dictionary must contain S entry');
     }
     switch ($dictionary->S->value) {
         case 'GoTo':
             return new GoToAction($dictionary, $processedActions);
             brake;
         case 'GoToR':
             return new GoToR($dictionary, $processedActions);
             brake;
         case 'GoToE':
             return new GoToE($dictionary, $processedActions);
             brake;
         case 'Launch':
             return new Launch($dictionary, $processedActions);
             brake;
         case 'Thread':
             return new Thread($dictionary, $processedActions);
             brake;
         case 'URI':
             return new URI($dictionary, $processedActions);
             brake;
         case 'Sound':
             return new Sound($dictionary, $processedActions);
             brake;
         case 'Movie':
             return new Movie($dictionary, $processedActions);
             brake;
         case 'Hide':
             return new Hide($dictionary, $processedActions);
             brake;
         case 'Named':
             return new Named($dictionary, $processedActions);
             brake;
         case 'SubmitForm':
             return new SubmitForm($dictionary, $processedActions);
             brake;
         case 'ResetForm':
             return new ResetForm($dictionary, $processedActions);
             brake;
         case 'ImportData':
             return new ImportData($dictionary, $processedActions);
             brake;
         case 'JavaScript':
             return new JavaScript($dictionary, $processedActions);
             brake;
         case 'SetOCGState':
             return new SetOCGState($dictionary, $processedActions);
             brake;
         case 'Rendition':
             return new Rendition($dictionary, $processedActions);
             brake;
         case 'Trans':
             return new Trans($dictionary, $processedActions);
             brake;
         case 'GoTo3DView':
             return new GoTo3DView($dictionary, $processedActions);
             brake;
         default:
             return new Unknown($dictionary, $processedActions);
             brake;
     }
 }

作者:bradley-hol    项目:zf   
/**
  * Render the completed PDF to a string.
  * If $newSegmentOnly is true, then only appended part of PDF is returned.
  *
  * @param boolean $newSegmentOnly
  * @param resource $outputStream
  * @return string
  * @throws \Zend\Pdf\Exception
  */
 public function render($newSegmentOnly = false, $outputStream = null)
 {
     // Save document properties if necessary
     if ($this->properties != $this->_originalProperties) {
         $docInfo = $this->_objFactory->newObject(new InternalType\DictionaryObject());
         foreach ($this->properties as $key => $value) {
             switch ($key) {
                 case 'Trapped':
                     switch ($value) {
                         case true:
                             $docInfo->{$key} = new InternalType\NameObject('True');
                             break;
                         case false:
                             $docInfo->{$key} = new InternalType\NameObject('False');
                             break;
                         case null:
                             $docInfo->{$key} = new InternalType\NameObject('Unknown');
                             break;
                         default:
                             throw new Exception\LogicException('Wrong Trapped document property vale: \'' . $value . '\'. Only true, false and null values are allowed.');
                             break;
                     }
                 case 'CreationDate':
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 case 'ModDate':
                     $docInfo->{$key} = new InternalType\StringObject((string) $value);
                     break;
                 case 'Title':
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 case 'Author':
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 case 'Subject':
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 case 'Keywords':
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 case 'Creator':
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                     // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 // break intentionally omitted
                 case 'Producer':
                     if (extension_loaded('mbstring') === true) {
                         $detected = mb_detect_encoding($value);
                         if ($detected !== 'ASCII') {
                             $value = chr(254) . chr(255) . mb_convert_encoding($value, 'UTF-16', $detected);
                         }
                     }
                     $docInfo->{$key} = new InternalType\StringObject((string) $value);
                     break;
                 default:
                     // Set property using PDF type based on PHP type
                     $docInfo->{$key} = InternalType\AbstractTypeObject::phpToPDF($value);
//.........这里部分代码省略.........

作者:niallmccrudde    项目:zf   
/**
     * Annotation object constructor
     *
     * @throws \Zend\Pdf\Exception\ExceptionInterface
     */
    public function __construct(InternalType\AbstractTypeObject $annotationDictionary)
    {
        if ($annotationDictionary->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) {
            throw new Exception\CorruptedPdfException('Annotation dictionary resource has to be a dictionary.');
        }

        $this->_annotationDictionary = $annotationDictionary;

        if ($this->_annotationDictionary->Type !== null  &&
            $this->_annotationDictionary->Type->value != 'Annot') {
            throw new Exception\CorruptedPdfException('Wrong resource type. \'Annot\' expected.');
        }

        if ($this->_annotationDictionary->Rect === null) {
            throw new Exception\CorruptedPdfException('\'Rect\' dictionary entry is required.');
        }

        if (count($this->_annotationDictionary->Rect->items) != 4 ||
            $this->_annotationDictionary->Rect->items[0]->getType() != InternalType\AbstractTypeObject::TYPE_NUMERIC ||
            $this->_annotationDictionary->Rect->items[1]->getType() != InternalType\AbstractTypeObject::TYPE_NUMERIC ||
            $this->_annotationDictionary->Rect->items[2]->getType() != InternalType\AbstractTypeObject::TYPE_NUMERIC ||
            $this->_annotationDictionary->Rect->items[3]->getType() != InternalType\AbstractTypeObject::TYPE_NUMERIC ) {
            throw new Exception\CorruptedPdfException('\'Rect\' dictionary entry must be an array of four numeric elements.');
        }
    }

作者:rexma    项目:zf   
/**
  * Create PDF outline object using specified dictionary
  *
  * @internal
  * @param \Zend\Pdf\InternalType\AbstractTypeObject $dictionary (It's actually Dictionary or Dictionary Object or Reference to a Dictionary Object)
  * @param \Zend\Pdf\Action\AbstractAction  $parentAction
  * @param SplObjectStorage $processedOutlines  List of already processed Outline dictionaries,
  *                                             used to avoid cyclic references
  * @return \Zend\Pdf\Action\AbstractAction
  * @throws \Zend\Pdf\Exception
  */
 public function __construct(InternalType\AbstractTypeObject $dictionary, \SplObjectStorage $processedDictionaries = null)
 {
     if ($dictionary->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) {
         throw new Exception\CorruptedPdfException('$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() != InternalType\AbstractTypeObject::TYPE_NUMERIC) {
             throw new Exception\CorruptedPdfException('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;
         for ($count = 0; $count < $childOutlinesCount; $count++) {
             if ($childDictionary === null) {
                 throw new Exception\CorruptedPdfException('Outline childs load error.');
             }
             if (!$processedDictionaries->contains($childDictionary)) {
                 $this->childOutlines[] = new Loaded($childDictionary, $processedDictionaries);
             }
             $childDictionary = $childDictionary->Next;
         }
         if ($childDictionary !== null) {
             throw new Exception\CorruptedPdfException('Outline childs load error.');
         }
         $this->_originalChildOutlines = $this->childOutlines;
     }
 }

作者:alab100110    项目:zf   
/**
  * Set top level parent indirect object.
  *
  * @param \Zend\Pdf\InternalType\IndirectObject $parent
  */
 public function setParentObject(IndirectObject $parent)
 {
     parent::setParentObject($parent);
     foreach ($this->_items as $item) {
         $item->setParentObject($parent);
     }
 }

作者:stunt    项目:zf   
/**
  * Convert PDF element to PHP type.
  *
  * @return mixed
  */
 public function toPhp()
 {
     return $this->_value->toPhp();
 }


问题


面经


文章

微信
公众号

扫码关注公众号