Exemplo n.º 1
0
 /**
  * Annotation object constructor
  *
  * @throws \ZendPdf\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 != 'Text') {
         throw new Exception\CorruptedPdfException('Subtype => Text entry is requires');
     }
     parent::__construct($annotationDictionary);
 }
Exemplo n.º 2
0
 /**
  * Annotation object constructor
  *
  * @throws \ZendPdf\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 || !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);
 }
Exemplo n.º 3
0
 /**
  *
  * @param \ZendPdf\Annotation\AbstractAnnotation $annotation
  * @return \ZendPdf\Page
  */
 public function attachAnnotation(Annotation\AbstractAnnotation $annotation)
 {
     $annotationDictionary = $annotation->getResource();
     if (!$annotationDictionary instanceof InternalType\IndirectObject && !$annotationDictionary instanceof InternalType\IndirectObjectReference) {
         $annotationDictionary = $this->_objFactory->newObject($annotationDictionary);
     }
     if ($this->_pageDictionary->Annots === null) {
         $this->_pageDictionary->touch();
         $this->_pageDictionary->Annots = new InternalType\ArrayObject();
     } else {
         $this->_pageDictionary->Annots->touch();
     }
     $this->_pageDictionary->Annots->items[] = $annotationDictionary;
     $annotationDictionary->touch();
     $annotationDictionary->P = $this->_pageDictionary;
     return $this;
 }