Example #1
0
 /**
  * Create a new Title Element
  *
  * @param string $text
  * @param int $depth
  */
 public function __construct($text, $depth = 1)
 {
     $this->text = StringElement::toUTF8($text);
     $this->depth = $depth;
     if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) {
         $this->style = "Heading{$this->depth}";
     }
     return $this;
 }
Example #2
0
 /**
  * Create a new Link Element
  *
  * @param string $source
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
 {
     $this->source = StringElement::toUTF8($source);
     $this->text = is_null($text) ? $this->source : StringElement::toUTF8($text);
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->internal = $internal;
     return $this;
 }
Example #3
0
 /**
  * Create a new ListItem
  *
  * @param string $text
  * @param int $depth
  * @param mixed $fontStyle
  * @param array|string|null $listStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
 {
     $this->textObject = new Text(StringElement::toUTF8($text), $fontStyle, $paragraphStyle);
     $this->depth = $depth;
     // Version >= 0.10.0 will pass numbering style name. Older version will use old method
     if (!is_null($listStyle) && is_string($listStyle)) {
         $this->style = new ListItemStyle($listStyle);
     } else {
         $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
     }
 }
Example #4
0
 /**
  * Create a new Preserve Text Element
  *
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  * @return self
  */
 public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
 {
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->text = StringElement::toUTF8($text);
     $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     if (isset($matches[0])) {
         $this->text = $matches;
     }
     return $this;
 }
Example #5
0
 /**
  * Set text content
  *
  * @param string $text
  * @return self
  */
 public function setText($text)
 {
     $this->text = StringElement::toUTF8($text);
     return $this;
 }
Example #6
0
 /**
  * Create a new Bookmark Element
  *
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = StringElement::toUTF8($name);
     return $this;
 }
Example #7
0
 /**
  * Set name content
  *
  * @param string $name
  * @return self
  */
 public function setName($name)
 {
     $this->name = StringElement::toUTF8($name);
     return $this;
 }