Esempio n. 1
0
 /**
  * Gets rtf code of footer
  *
  * @return string rtf code
  */
 public function getContent()
 {
     $content = isset($this->_offsetHeight) ? '\\footery' . round(PHPRtfLite::TWIPS_IN_CM * $this->_offsetHeight) . ' ' : '';
     $content .= '{\\' . $this->getTypeAsRtfCode() . ' ' . parent::getContent() . '\\par ' . '}';
     return $content . "\r\n";
 }
Esempio n. 2
0
 /**
  * Gets rtf code of section.
  * @return string rtf code
  */
 public function getContent()
 {
     $content = '';
     //section is not first section
     if (!$this->_isFirst) {
         $content .= '\\sect \\sectd ';
     }
     //headers
     $headers = $this->_headers ? $this->_headers : $this->_rtf->getHeaders();
     if (!empty($headers)) {
         foreach ($headers as $value) {
             $content .= $value->getContent();
         }
     }
     //footers
     $footers = $this->_footers ? $this->_footers : $this->_rtf->getFooters();
     if (!empty($footers)) {
         foreach ($footers as $value) {
             $content .= $value->getContent();
         }
     }
     //borders
     $border = $this->_border ? $this->_border : $this->_rtf->getBorder();
     if ($border) {
         $content .= $border->getContent($this->_rtf, '\\pg');
     }
     //do not break within the section
     if ($this->_doNotBreak) {
         $content .= '\\sbknone ';
     }
     //set column index, when using more than one column for this section
     if ($this->_numberOfColumns > 1) {
         $content .= '\\cols' . $this->_numberOfColumns . ' ';
     }
     if ($this->_columnWidths === null) {
         if ($this->_spaceBetweenColumns) {
             $content .= '\\colsx' . round($this->_spaceBetweenColumns * PHPRtfLite::TWIPS_IN_CM) . ' ';
         }
     } else {
         $width = 0;
         foreach ($this->_columnWidths as $value) {
             $width += $value * PHPRtfLite::TWIPS_IN_CM;
         }
         $printableWidth = $this->_rtf->getPaperWidth() - $this->_rtf->getMarginLeft() - $this->_rtf->getMarginRight();
         $space = round(($printableWidth * PHPRtfLite::TWIPS_IN_CM - $width) / (count($this->_columnWidths) - 1));
         $i = 1;
         foreach ($this->_columnWidths as $key => $value) {
             $content .= '\\colno' . $i . '\\colw' . $value * PHPRtfLite::TWIPS_IN_CM;
             if (!empty($this->_columnWidths[$key])) {
                 $content .= '\\colsr' . $space;
             }
             $i++;
         }
         $content .= ' ';
     }
     if ($this->_lineBetweenColumns) {
         $content .= '\\linebetcol ';
     }
     /*---Page part---*/
     if ($this->_paperWidth) {
         $content .= '\\pgwsxn' . round($this->_paperWidth * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_paperHeight) {
         $content .= '\\pghsxn' . round($this->_paperHeight * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_marginLeft) {
         $content .= '\\marglsxn' . round($this->_marginLeft * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_marginRight) {
         $content .= '\\margrsxn' . round($this->_marginRight * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_marginTop) {
         $content .= '\\margtsxn' . round($this->_marginTop * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_marginBottom) {
         $content .= '\\margbsxn' . round($this->_marginBottom * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_gutter) {
         $content .= '\\guttersxn' . round($this->_gutter * PHPRtfLite::TWIPS_IN_CM) . ' ';
     }
     if ($this->_useMirrorMargins) {
         $content .= '\\margmirsxn ';
     }
     if ($this->_verticalAlignment) {
         switch ($this->_verticalAlignment) {
             case 'center':
                 $content .= '\\vertalc ';
                 break;
             case 'bottom':
                 $content .= '\\vertalb ';
                 break;
             case 'justify':
                 $content .= '\\vertalj ';
                 break;
             default:
                 $content .= '\\vertalt ';
                 break;
         }
     }
     $content .= "\r\n" . parent::getContent() . "\r\n";
     return $content;
 }
Esempio n. 3
0
 /**
  * Gets rtf code for cell
  *
  * @return string rtf code
  */
 public function getContent()
 {
     $content = '{';
     switch ($this->_alignment) {
         case self::TEXT_ALIGN_LEFT:
             $content .= '\\ql';
             break;
         case self::TEXT_ALIGN_CENTER:
             $content .= '\\qc';
             break;
         case self::TEXT_ALIGN_RIGHT:
             $content .= '\\qr';
             break;
         case self::TEXT_ALIGN_JUSTIFY:
             $content .= '\\qj';
             break;
     }
     if ($this->_font) {
         $content .= $this->_font->getContent($this->_table->getRtf());
     }
     $content .= parent::getContent() . '\\cell \\pard }' . "\r\n";
     return $content;
 }