예제 #1
0
 /**
  * Sets border to a cell
  *
  * @param PHPRtfLite_Border $border
  */
 public function setBorder(PHPRtfLite_Border $border)
 {
     $borderFormatTop = $border->getBorderTop();
     $borderFormatBottom = $border->getBorderBottom();
     $borderFormatLeft = $border->getBorderLeft();
     $borderFormatRight = $border->getBorderRight();
     if (!$this->_border) {
         $this->_border = new PHPRtfLite_Border();
     }
     if ($borderFormatLeft) {
         $this->_border->setBorderLeft($borderFormatLeft);
     }
     if ($borderFormatRight) {
         $this->_border->setBorderRight($borderFormatRight);
     }
     if ($borderFormatTop) {
         $this->_border->setBorderTop($borderFormatTop);
     }
     if ($borderFormatBottom) {
         $this->_border->setBorderBottom($borderFormatBottom);
     }
     if ($borderFormatTop && $this->_table->checkIfCellExists($this->_rowIndex - 1, $this->_columnIndex)) {
         $cell = $this->_table->getCell($this->_rowIndex - 1, $this->_columnIndex);
         $borderBottom = $cell->getBorder();
         if ($borderBottom == null) {
             $borderBottom = new PHPRtfLite_Border();
         }
         $borderBottom->setBorderBottom($borderFormatTop);
         $cell->setCellBorder($borderBottom);
     }
     if ($borderFormatBottom && $this->_table->checkIfCellExists($this->_rowIndex + 1, $this->_columnIndex)) {
         $cell = $this->_table->getCell($this->_rowIndex + 1, $this->_columnIndex);
         $borderTop = $cell->getBorder();
         if ($borderTop == null) {
             $borderTop = new PHPRtfLite_Border();
         }
         $borderTop->setBorderTop($borderFormatBottom);
         $cell->setCellBorder($borderTop);
     }
     if ($borderFormatLeft && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex - 1)) {
         $cell = $this->_table->getCell($this->_rowIndex, $this->_columnIndex - 1);
         $borderRight = $cell->getBorder();
         if ($borderRight == null) {
             $borderRight = new PHPRtfLite_Border();
         }
         $borderRight->setBorderRight($borderFormatLeft);
         $cell->setCellBorder($borderRight);
     }
     if ($borderFormatRight && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex + 1)) {
         $cell = $this->_table->getCell($this->_rowIndex, $this->_columnIndex + 1);
         $borderLeft = $cell->getBorder();
         if ($borderLeft == null) {
             $borderLeft = new PHPRtfLite_Border();
         }
         $borderLeft->setBorderLeft($borderFormatRight);
         $cell->setCellBorder($borderLeft);
     }
 }
예제 #2
0
 /**
  * Sets borders to rtf document.
  *
  * @param PHPRtfLite_Border_Format  $borderFormat
  * @param boolean                   $left
  * @param boolean                   $top
  * @param boolean                   $right
  * @param boolean                   $bottom
  */
 public function setBorders(PHPRtfLite_Border_Format $borderFormat, $left = true, $top = true, $right = true, $bottom = true)
 {
     if ($this->_border === null) {
         $this->_border = new PHPRtfLite_Border();
     }
     if ($left) {
         $this->_border->setBorderLeft($borderFormat);
     }
     if ($top) {
         $this->_border->setBorderTop($borderFormat);
     }
     if ($right) {
         $this->_border->setBorderRight($borderFormat);
     }
     if ($bottom) {
         $this->_border->setBorderBottom($borderFormat);
     }
 }
예제 #3
0
$table->addColumnsList(array(7.5, 6.5));
$table->writeToCell(1, 1, '<br> Sample borders', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$cell = $table->getCell(1, 2);
$cell->writeText('<br>   ', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$img = $cell->addImage($dir . '/sources/cats.jpg', null);
$border = PHPRtfLite_Border::create($rtf, 3, '#000000');
$img->setBorder($border);
$table->writeToCell(2, 1, '<br> Borders with space', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat());
$cell = $table->getCell(2, 2);
$img = $cell->addImage($dir . '/sources/cats.jpg', null);
$borderFormatBlue = new PHPRtfLite_Border_Format(2, '#0000ff', 'simple', 0.5);
$borderFormatRed = new PHPRtfLite_Border_Format(2, '#ff0000', 'simple', 0.5);
$border = new PHPRtfLite_Border($rtf);
$border->setBorderLeft($borderFormatRed);
$border->setBorderTop($borderFormatBlue);
$border->setBorderRight($borderFormatRed);
$border->setBorderBottom($borderFormatBlue);
$img->setBorder($border);
$table->writeToCell(3, 1, '<br> Image centered by ParFormat', new PHPRtfLite_Font());
$cell = $table->getCell(3, 2);
$parFormatCenter = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER);
$img = $cell->addImage($dir . '/sources/cats.jpg', $parFormatCenter);
$table->writeToCell(4, 1, '<br> Image centered horizontal and vertically by cell', new PHPRtfLite_Font());
$cell = $table->getCell(4, 2);
$cell->setTextAlignment(PHPRtfLite_Table_Cell::TEXT_ALIGN_CENTER);
$cell->setVerticalAlignment(PHPRtfLite_Table_Cell::VERTICAL_ALIGN_CENTER);
$img = $cell->addImage($dir . '/sources/cats.jpg');
$sect->writeText('<b>Images in paragraph</b><br><br>', new PHPRtfLite_Font(), $parGreyLeft);
$img = $sect->addImage($dir . '/sources/html.png', $parGreyCenter);
$img->setWidth(1.5);
// save rtf document