Exemple #1
0
 /**
  * Add a Title Element
  * 
  * @param string $text
  * @param int $depth
  * @return PHPWord_Section_Title
  */
 public function addTitle($text, $depth = 1)
 {
     $styles = PHPWord_Style::getStyles();
     if (array_key_exists('Heading_' . $depth, $styles)) {
         $style = 'Heading' . $depth;
     } else {
         $style = null;
     }
     $title = new PHPWord_Section_Title($text, $depth, $style);
     $data = PHPWord_TOC::addTitle($text, $depth);
     $anchor = $data[0];
     $bookmarkId = $data[1];
     $title->setAnchor($anchor);
     $title->setBookmarkId($bookmarkId);
     $this->_elementCollection[] = $title;
     return $title;
 }