/**
  * Simplified header printing with PDF bookmarks
  */
 function header($text, $level, $pos)
 {
     if (!$text) {
         return;
     }
     //skip empty headlines
     global $ID;
     $hid = $this->_headerToLink($text, true);
     $check = false;
     $pid = sectionID($ID, $check);
     $hid = $pid . '__' . $hid;
     // add PDF bookmark
     $bookmark = '';
     $bmlevel = $this->actioninstance->getExportConfig('maxbookmarks');
     if ($bmlevel && $bmlevel >= $level) {
         // PDF readers choke on invalid nested levels
         if ($this->lastheadlevel == -1) {
             $this->lastheadlevel = $level;
         }
         $step = $level - $this->lastheadlevel;
         if ($step > 0) {
             $this->current_bookmark_level += 1;
         } else {
             if ($step < 0) {
                 $this->current_bookmark_level -= 1;
                 if ($this->current_bookmark_level < 0) {
                     $this->current_bookmark_level = 0;
                 }
             }
         }
         $this->lastheadlevel = $level;
         $bookmark = '<bookmark content="' . $this->_xmlEntities($text) . '" level="' . $this->current_bookmark_level . '" />';
     }
     // print header
     $this->doc .= DOKU_LF . "<h{$level}>{$bookmark}";
     $this->doc .= "<a name=\"{$hid}\">";
     $this->doc .= $this->_xmlEntities($text);
     $this->doc .= "</a>";
     $this->doc .= "</h{$level}>" . DOKU_LF;
 }