/** * Set text to be displayed for the annotation or, if this type of annotation * does not display text, an alternate description of the annotation’s contents * in human-readable form. * * @param string $text * @return \Zend\Pdf\Annotation\AbstractAnnotation */ public function setText($text) { if ($this->_annotationDictionary->Contents === null) { $this->_annotationDictionary->touch(); $this->_annotationDictionary->Contents = new InternalType\StringObject($text); } else { $this->_annotationDictionary->Contents->touch(); $this->_annotationDictionary->Contents->value = new InternalType\StringObject($text); } return $this; }
/** * Load pages recursively * * @param \Zend\Pdf\InternalType\IndirectObjectReference $pages * @param array|null $attributes */ protected function _loadPages(InternalType\IndirectObjectReference $pages, $attributes = array()) { if ($pages->getType() != InternalType\AbstractTypeObject::TYPE_DICTIONARY) { throw new Exception\CorruptedPdfException('Wrong argument'); } foreach ($pages->getKeys() as $property) { if (in_array($property, self::$_inheritableAttributes)) { $attributes[$property] = $pages->{$property}; $pages->{$property} = null; } } foreach ($pages->Kids->items as $child) { if ($child->Type->value == 'Pages') { $this->_loadPages($child, $attributes); } else { if ($child->Type->value == 'Page') { foreach (self::$_inheritableAttributes as $property) { if ($child->{$property} === null && array_key_exists($property, $attributes)) { /** * Important note. * If any attribute or dependant object is an indirect object, then it's still * shared between pages. */ if ($attributes[$property] instanceof InternalType\IndirectObject || $attributes[$property] instanceof InternalType\IndirectObjectReference) { $child->{$property} = $attributes[$property]; } else { $child->{$property} = $this->_objFactory->newObject($attributes[$property]); } } } $this->pages[] = new Page($child, $this->_objFactory); } } } }