/** * tests setBorder on cell 2x2 * @depends testSetBorderForCellWithRow2Column1 * * @param PHPRtfLite_Table $table */ public function testSetBorderForCellWithRow2Column2(PHPRtfLite_Table $table) { $border = new PHPRtfLite_Border($table->getRtf()); $border->setBorders(new PHPRtfLite_Border_Format(1, '#888')); $cell2x2 = $table->getCell(2, 2); $cell1x2 = $table->getCell(1, 2); $cell2x1 = $table->getCell(2, 1); $cell2x2->setBorder($border); $this->assertEquals('#3F3', $cell1x2->getBorder()->getBorderTop()->getColor()); $this->assertEquals('#888', $cell1x2->getBorder()->getBorderBottom()->getColor()); $this->assertEquals('#888', $cell2x1->getBorder()->getBorderRight()->getColor()); }
/** * 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($this->_rtf); } $this->_border->setBorders($borderFormat, $left, $top, $right, $bottom); }
/** * tests setBorders */ public function testSetBorders() { $borderFormat = new PHPRtfLite_Border_Format(1.5, '#ff0', PHPRtfLite_Border_Format::TYPE_SINGLE); $this->_border->setBorders($borderFormat); $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderTop()); $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderBottom()); $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderRight()); $this->assertType('PHPRtfLite_Border_Format', $this->_border->getBorderLeft()); }
/** * 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); } }
/** * writes image into rtf stream * * @param integer $startFrom */ protected function writeIntoRtfStream($startFrom = 0) { fseek($this->_stream, $startFrom); $rtfImageType = $this->getImageTypeAsRtf(); $rtfStream = $this->_rtf->getWriter(); $rtfStream->write('{\\*\\shppict {\\pict'); if ($this->_border) { $rtfStream->write($this->_border->getContent()); } $rtfStream->write($rtfImageType . '\\picscalex100\\picscaley100'); $rtfStream->write('\\picwgoal' . $this->getImageRtfWidth()); $rtfStream->write('\\pichgoal' . $this->getImageRtfHeight()); $rtfStream->write(' '); while (!feof($this->_stream)) { $stringBuffer = fread($this->_stream, 1024); $stringHex = bin2hex($stringBuffer); $rtfStream->write($stringHex); } $rtfStream->write('}}'); }
/** * @deprecated use setBorder() instead * @see PHPRtfLite/PHPRtfLite_Cell#setBorder() * * Sets border to cell * * @param PHPRtfLite_BorderFormat $borderFormat * @param boolean $left if false, left border is not set (default true) * @param boolean $top if false, top border is not set (default true) * @param boolean $right if false, right border is not set (default true) * @param boolean $bottom if false, bottom border is not set (default true) */ public function setBorders(PHPRtfLite_Border_Format $borderFormat, $left = true, $top = true, $right = true, $bottom = true) { $border = new PHPRtfLite_Border(); $border->setBorders($borderFormat, $left, $top, $right, $bottom); $this->setBorder($border); }
/** * Save the current file * @param $filename file name */ public function save($filename) { // instancia um objeto para estilo de borda $border = PHPRtfLite_Border::create(0.7, '#000000'); // liga as bordas na tabela $this->table->setBorderForCellRange($border, 1, 1, $this->table->getRowsCount(), $this->table->getColumnsCount()); // armazena o documento em um arquivo $this->rtf->save($filename); return TRUE; }
$smallWidth = '0.75'; $bigWidth = ($sect->getLayoutWidth() - $countSmall * $smallWidth) / $countLarge; $table = $sect->addTable(); $table->addRows(16, -0.5); $table->addColumnsList(array($smallWidth, $bigWidth, $bigWidth, $smallWidth, $smallWidth, $bigWidth, $bigWidth, $smallWidth, $smallWidth, $bigWidth, $bigWidth)); $table->setTextAlignmentForCellRange('center', 1, 1, 16, 11); $table->setFontForCellRange(new PHPRtfLite_Font(11, 'Times new Roman', '#7A2900'), 1, 1, 16, 11); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 2, 1, 3, 3); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 6, 1, 7, 3); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 10, 1, 11, 3); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 14, 1, 15, 3); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 4, 5, 5, 7); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 12, 5, 13, 7); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 8, 9, 9, 11); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 14, 9, 15, 11); $table->setBorderForCellRange(PHPRtfLite_Border::create($rtf, 1), 1, 10, 3, 11); $table->writeToCell(2, 1, 'P1', $font1, null); $table->writeToCell(3, 1, 'P8', $font1, null); $table->writeToCell(6, 1, 'P2', $font1, null); $table->writeToCell(7, 1, 'P7', $font1, null); $table->writeToCell(10, 1, 'P3', $font1, null); $table->writeToCell(11, 1, 'P6', $font1, null); $table->writeToCell(14, 1, 'P4', $font1, null); $table->writeToCell(15, 1, 'P5', $font1, null); $table->writeToCell(1, 1, 'A1', $font1, null); $table->writeToCell(5, 1, 'A2', $font1, null); $table->writeToCell(9, 1, 'A3', $font1, null); $table->writeToCell(13, 1, 'A4', $font1, null); $table->writeToCell(3, 5, 'B1', $font1, null); $table->writeToCell(4, 5, 'A1', $font1, null); $table->writeToCell(5, 5, 'A2', $font1, null);
/** * prepares rtf contents */ protected function prepare() { $part = $this->getInfoPart(); //page properties $part .= $this->_isLandscape ? '\\landscape ' : ''; $part .= '\\deftab' . round(self::TWIPS_IN_CM * $this->_defaultTabWidth) . ' '; $part .= '\\paperw' . round(self::TWIPS_IN_CM * $this->_paperWidth) . ' '; $part .= '\\paperh' . round(self::TWIPS_IN_CM * $this->_paperHeight) . ' '; $part .= '\\margl' . round(self::TWIPS_IN_CM * $this->_marginLeft) . ' '; $part .= '\\margr' . round(self::TWIPS_IN_CM * $this->_marginRight) . ' '; $part .= '\\margt' . round(self::TWIPS_IN_CM * $this->_marginTop) . ' '; $part .= '\\margb' . round(self::TWIPS_IN_CM * $this->_marginBottom) . ' '; if (null !== $this->_gutter) { $part .= '\\gutter' . round($this->_gutter * self::TWIPS_IN_CM) . ' '; } if (true == $this->_useMirrorMargins) { $part .= '\\margmirror '; } if (null !== $this->_viewMode) { $part .= '\\viewkind' . $this->_viewMode . ' '; } if (null !== $this->_zoomMode) { $part .= '\\viewzk' . $this->_zoomMode . ' '; } if (null !== $this->_zoomLevel) { $part .= '\\viewscale' . $this->_zoomLevel . ' '; } if ($this->_sections[0] && $this->_sections[0]->getBorder()) { $part .= $this->_sections[0]->getBorder()->getContent($this, '\\pg'); } elseif ($this->_border) { $part .= $this->_border->getContent($this, '\\pg'); } //headers and footers properties if ($this->_useOddEvenDifferent) { $part .= '\\facingp '; } if ($this->_titlepg) { $part .= '\\titlepg '; } // document header definiton for footnotes and endnotes $part .= $this->getNoteDocHeadDefinition()->getContent(); //headers and footers if there are no sections if (count($this->_sections) == 0) { foreach ($this->_headers as $header) { $part .= $header->getContent(); } foreach ($this->_footers as $footer) { $part .= $footer->getContent(); } } //sections foreach ($this->_sections as $key => $section) { $part .= $section->getContent(); } $this->_content = '{\\rtf\\ansi\\deff0 \\r\\n'; $this->_content .= $this->getFontTable(); $this->_content .= $this->getColorTable(); $this->_content .= $part . '}'; }
/** * prepares rtf contents */ protected function render() { $this->_writer->open(); $this->_writer->write('{\\rtf\\ansi\\deff0' . "\r\n"); $this->_writer->write($this->getFontTable()->getContent()); $this->_writer->write($this->getColorTable()->getContent()); $this->_writer->write($this->getInfoPart()); $paperWidth = $this->_paperWidth; $paperHeight = $this->_paperHeight; // page properties if ($this->_isLandscape) { $this->_writer->write('\\landscape '); if ($paperWidth < $paperHeight) { $tmp = $paperHeight; $paperHeight = $paperWidth; $paperWidth = $tmp; } } $this->_writer->write('\\paperw' . PHPRtfLite_Unit::getUnitInTwips($paperWidth) . ' '); $this->_writer->write('\\paperh' . PHPRtfLite_Unit::getUnitInTwips($paperHeight) . ' '); // hyphenation if ($this->_isHyphenation) { $this->_writer->write('\\hyphauto1'); } $this->_writer->write('\\deftab' . PHPRtfLite_Unit::getUnitInTwips($this->_defaultTabWidth) . ' '); $this->_writer->write('\\margl' . PHPRtfLite_Unit::getUnitInTwips($this->_marginLeft) . ' '); $this->_writer->write('\\margr' . PHPRtfLite_Unit::getUnitInTwips($this->_marginRight) . ' '); $this->_writer->write('\\margt' . PHPRtfLite_Unit::getUnitInTwips($this->_marginTop) . ' '); $this->_writer->write('\\margb' . PHPRtfLite_Unit::getUnitInTwips($this->_marginBottom) . ' '); if (null !== $this->_gutter) { $this->_writer->write('\\gutter' . PHPRtfLite_Unit::getUnitInTwips($this->_gutter) . ' '); } if (true == $this->_useMirrorMargins) { $this->_writer->write('\\margmirror '); } if (null !== $this->_viewMode) { $this->_writer->write('\\viewkind' . $this->_viewMode . ' '); } if (null !== $this->_zoomMode) { $this->_writer->write('\\viewzk' . $this->_zoomMode . ' '); } if (null !== $this->_zoomLevel) { $this->_writer->write('\\viewscale' . $this->_zoomLevel . ' '); } if (isset($this->_sections[0]) && $this->_sections[0]->getBorder()) { $this->_writer->write($this->_sections[0]->getBorder()->getContent('\\pg')); } elseif ($this->_border) { $this->_writer->write($this->_border->getContent('\\pg')); } // page numbering start $this->_writer->write('\\pgnstart' . $this->_pageNumberStart); //headers and footers properties if ($this->_useOddEvenDifferent) { $this->_writer->write('\\facingp '); } if ($this->_titlepg) { $this->_writer->write('\\titlepg '); } // document header definition for footnotes and endnotes $this->_writer->write($this->getNoteDocHead()->getContent()); //headers and footers if there are no sections if (count($this->_sections) == 0) { foreach ($this->_headers as $header) { $header->render(); } foreach ($this->_footers as $footer) { $footer->render(); } } //sections foreach ($this->_sections as $key => $section) { if ($key != 0) { $this->_writer->write('\\sect\\sectd '); } $section->render(); } $this->_writer->write('}'); $this->_writer->close(); }
/** * gets rtf code of paragraph * * @return string rtf code */ public function getContent() { $content = ''; switch ($this->_alignment) { case self::TEXT_ALIGN_RIGHT: $content .= '\\qr '; break; case self::TEXT_ALIGN_CENTER: $content .= '\\qc '; break; case self::TEXT_ALIGN_JUSTIFY: $content .= '\\qj '; break; default: $content .= '\\ql '; break; } if ($this->_indentFirstLine != 0) { $content .= '\\fi' . PHPRtfLite_Unit::getUnitInTwips($this->_indentFirstLine) . ' '; } if ($this->_indentLeft > 0) { $content .= '\\li' . PHPRtfLite_Unit::getUnitInTwips($this->_indentLeft) . ' '; } if ($this->_indentRight > 0) { $content .= '\\ri' . PHPRtfLite_Unit::getUnitInTwips($this->_indentRight) . ' '; } if ($this->_spaceBefore > 0) { $content .= '\\sb' . $this->_spaceBefore . ' '; } if ($this->_spaceAfter > 0) { $content .= '\\sa' . $this->_spaceAfter . ' '; } if ($this->_spaceBetweenLines > 0) { $content .= '\\sl' . $this->_spaceBetweenLines . ' '; } if ($this->_border) { $content .= $this->_border->getContent('\\'); } if ($this->_shading > 0) { $content .= '\\shading' . $this->_shading . ' '; } if ($this->_backgroundColor && $this->_colorTable) { $colorIndex = $this->_colorTable->getColorIndex($this->_backgroundColor); if ($colorIndex !== false) { $content .= '\\cbpat' . $colorIndex . ' '; } } return $content; }
$sect = $rtf->addSection(); $table = $sect->addTable(); $table->addRows($rowCount, $rowHeight); $table->addColumnsList(array_fill(0, $columnCount, $columnWidth)); for ($rowIndex = 1; $rowIndex <= $rowCount; $rowIndex++) { for ($columnIndex = 1; $columnIndex <= $columnCount; $columnIndex++) { $cell = $table->getCell($rowIndex, $columnIndex); $cell->writeText("Cell {$rowIndex}:{$columnIndex}"); $cell->setTextAlignment(PHPRtfLite_Table_Cell::TEXT_ALIGN_CENTER); $cell->setVerticalAlignment(PHPRtfLite_Table_Cell::VERTICAL_ALIGN_CENTER); } } $borderTop = new PHPRtfLite_Border($rtf); $borderTop->setBorderTop(new PHPRtfLite_Border_Format(2, '#f33')); $table->setBorderForCellRange($borderTop, 1, 1, 1, $columnCount); $borderBottom = new PHPRtfLite_Border($rtf); $borderBottom->setBorderBottom(new PHPRtfLite_Border_Format(2, '#33f')); $table->setBorderForCellRange($borderBottom, $rowCount, 1, $rowCount, $columnCount); $sect->writeText('Table with cell paddings (Using Microsoft Word top and bottom cell paddings are applied to all cells in a row)'); $table = $sect->addTable(); $table->addRows(4); $table->addColumnsList(array_fill(0, 4, $columnWidth)); $cell = $table->getCell(1, 1); $cell->writeText('cell 1:1 (with left padding)'); $cell->setPaddingLeft(1); $cell = $table->getCell(2, 2); $cell->writeText('cell 2:2 (with right padding)'); $cell->setPaddingRight(1); $cell = $table->getCell(3, 3); $cell->writeText('cell 3:3 (with top padding)');
/** * 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 === null) { $this->_border = new PHPRtfLite_Border($this->_rtf); } 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)) { $this->getBorderForCell($this->_rowIndex - 1, $this->_columnIndex)->setBorderBottom($borderFormatTop); } if ($borderFormatBottom && $this->_table->checkIfCellExists($this->_rowIndex + 1, $this->_columnIndex)) { $this->getBorderForCell($this->_rowIndex + 1, $this->_columnIndex)->setBorderTop($borderFormatBottom); } if ($borderFormatLeft && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex - 1)) { $this->getBorderForCell($this->_rowIndex, $this->_columnIndex - 1)->setBorderRight($borderFormatLeft); } if ($borderFormatRight && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex + 1)) { $this->getBorderForCell($this->_rowIndex, $this->_columnIndex + 1)->setBorderLeft($borderFormatRight); } }
<?php $dir = dirname(__FILE__); require_once $dir . '/../lib/PHPRtfLite.php'; PHPRtfLite::registerAutoloader(); $rtf = new PHPRtfLite(); $sect = $rtf->addSection(); $table = $sect->addTable(); $table->addRows(5, 0.75); $table->addColumnsList(array(3, 3, 3, 3, 3)); $table->mergeCellRange(1, 1, 3, 1); $table->writeToCell(1, 1, 'Vertical merged cells.', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $border = PHPRtfLite_Border::create($rtf, 1, '#ff0000'); $table->setBorderForCellRange($border, 1, 1, 3, 1); $table->mergeCellRange(1, 3, 1, 5); $table->writeToCell(1, 3, 'Horizontal merged cells', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $border = PHPRtfLite_Border::create($rtf, 1, '#0000ff'); $table->setBorderForCellRange($border, 1, 3, 1, 5); $table->mergeCellRange(3, 3, 5, 5); $table->writeToCell(3, 3, 'Horizontal and vertical merged cells', new PHPRtfLite_Font(), new PHPRtfLite_ParFormat()); $border = PHPRtfLite_Border::create($rtf, 1, '#00ff00'); $table->setBorderForCellRange($border, 3, 3, 5, 5); // save rtf document $rtf->save($dir . '/generated/' . basename(__FILE__, '.php') . '.rtf');
/** * renders rtf code of section */ public function render() { $writer = $this->_rtf->getWriter(); //headers $headers = $this->_headers ? $this->_headers : $this->_rtf->getHeaders(); if (!empty($headers)) { foreach ($headers as $header) { $header->render(); } } //footers $footers = $this->_footers ? $this->_footers : $this->_rtf->getFooters(); if (!empty($footers)) { foreach ($footers as $footer) { $footer->render(); } } //borders if ($this->_border) { if ($this->_borderSurroundsHeader) { $writer->write('\\pgbrdrhead'); } if ($this->_borderSurroundsFooter) { $writer->write('\\pgbrdrfoot'); } $writer->write($this->_border->getContent('\\pg')); } else { if ($border = $this->_rtf->getBorder()) { if ($this->_rtf->borderSurroundsHeader()) { $writer->write('\\pgbrdrhead'); } if ($this->_rtf->borderSurroundsFooter()) { $writer->write('\\pgbrdrfoot'); } $writer->write($border->getContent('\\pg')); } } //do not break within the section if ($this->_doNotBreak) { $writer->write('\\sbknone '); } //set column index, when using more than one column for this section if ($this->_numberOfColumns > 1) { $writer->write('\\cols' . $this->_numberOfColumns . ' '); } if (empty($this->_columnWidths)) { if ($this->_spaceBetweenColumns) { $writer->write('\\colsx' . PHPRtfLite_Unit::getUnitInTwips($this->_spaceBetweenColumns) . ' '); } } else { $width = 0; foreach ($this->_columnWidths as $value) { $width += PHPRtfLite_Unit::getUnitInTwips($value); } $printableWidth = $this->_rtf->getPaperWidth() - $this->_rtf->getMarginLeft() - $this->_rtf->getMarginRight(); $space = round((PHPRtfLite_Unit::getUnitInTwips($printableWidth) - $width) / (count($this->_columnWidths) - 1)); $i = 1; foreach ($this->_columnWidths as $key => $value) { $writer->write('\\colno' . $i . '\\colw' . PHPRtfLite_Unit::getUnitInTwips($value)); if (!empty($this->_columnWidths[$key])) { $writer->write('\\colsr' . $space); } $i++; } $writer->write(' '); } if ($this->_lineBetweenColumns) { $writer->write('\\linebetcol '); } /*---Page part---*/ if ($this->_isLandscape) { $writer->write('\\lndscpsxn '); } if ($this->_paperWidth) { $writer->write('\\pgwsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_paperWidth) . ' '); } if ($this->_paperHeight) { $writer->write('\\pghsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_paperHeight) . ' '); } if ($this->_marginLeft) { $writer->write('\\marglsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginLeft) . ' '); } if ($this->_marginRight) { $writer->write('\\margrsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginRight) . ' '); } if ($this->_marginTop) { $writer->write('\\margtsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginTop) . ' '); } if ($this->_marginBottom) { $writer->write('\\margbsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginBottom) . ' '); } if ($this->_gutter) { $writer->write('\\guttersxn' . PHPRtfLite_Unit::getUnitInTwips($this->_gutter) . ' '); } if ($this->_useMirrorMargins) { $writer->write('\\margmirsxn '); } if ($this->_font) { $writer->write($this->_font->getContent()); } $writer->write("\r\n"); parent::render(); $writer->write("\r\n"); }
$table = $sect->addTable(); $table->addRows(2, 4.5); $table->addRows(2, 6); $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);
/** * @deprecated use setBorderForCellRange() instead * @see PHPRtfLite/PHPRtfLite_Table#setBorderForCellRange() * * Sets borders of cells. * * @param PHPRtfLite_Border_Format $borderFormat border format * @param integer $startRow start row * @param integer $startColumn start column * @param integer $endRow end row, if null, then border is set only to the row range. * @param integer $endColumn end column, if null, then border is set just to the column range. * @param boolean $left if false, left border is not set (default true) * @param boolean $top if false, top border is not set (default true) * @param boolean $right if false, right border is not set (default true) * @param boolean $bottom if false, bottom border is not set (default true) */ public function setBordersForCellRange(PHPRtfLite_Border_Format $borderFormat, $startRow, $startColumn, $endRow = null, $endColumn = null, $left = true, $top = true, $right = true, $bottom = true) { $border = new PHPRtfLite_Border($this->getRtf()); $border->setBorders($borderFormat, $left, $top, $right, $bottom); $this->setBorderForCellRange($border, $startRow, $startColumn, $endRow, $endColumn); }
$sect->setPaperHeight(16); $sect->setPaperWidth(25); //Borders overridden: No Borders $border = PHPRtfLite_Border::create($rtf, 0); $sect->setBorder($border); $sect->setSpaceBetweenColumns(1); $sect->setNumberOfColumns(2); $sect->setLineBetweenColumns(); writeSectionText($sect, $arial14, $times12, $text, $text2, $text3); //section 2 $sect = $rtf->addSection(); $sect->setBorderSurroundsHeader(); $sect->setBorderSurroundsFooter(); //Header overridden $header = $sect->addHeader(PHPRtfLite_Container_Header::TYPE_RIGHT); $header->writeText("PHPRtfLite class library. Overriden right section header. This is page - <pagenum> of <pagetotal> -", $times12, $parFormat); $header = $sect->addHeader(PHPRtfLite_Container_Header::TYPE_LEFT); $header->writeText("PHPRtfLite class library. Overriden left section header. This is page - <pagenum> of <pagetotal> -", $times12, $parFormat); //Borders overridden: Green border $border = PHPRtfLite_Border::create($rtf, 1, '#00ff00', PHPRtfLite_Border_Format::TYPE_DASH, 1); $sect->setBorder($border); writeSectionText($sect, $arial14, $times12, $text, $text2, $text3); // //section 3 $sect = $rtf->addSection(); $sect->setColumnWidths(array(3, 3, 8)); //Border from rtf //.... writeSectionText($sect, $arial14, $times12, $text, $text2, $text3); // save rtf document $rtf->save($dir . '/generated/' . basename(__FILE__, '.php') . '.rtf');