/** * tests getContent(). */ public function testGetContent() { $this->_font->setBold(); $this->_font->setItalic(); $this->_font->setUnderline(); $this->_font->setAnimation(PHPRtfLite_Font::ANIMATE_LAS_VEGAS_LIGHTS); $this->_font->setDoubleStriked(); $this->assertEquals('\\fs20 \\b \\i \\ul \\animtext1\\striked1 1', trim($this->_font->getContent())); }
/** * Add a new style * @param @stylename style name * @param @fontface font face * @param @fontsize font size * @param @fontstyle font style (B=bold, I=italic) * @param @fontcolor font color * @param @fillcolor fill color */ public function addStyle($stylename, $fontface, $fontsize, $fontstyle, $fontcolor, $fillcolor) { // instancia um objeto para estilo de fonte (PHPRtfLite_Font) $font = new PHPRtfLite_Font($fontsize, $fontface, $fontcolor); $font->setBold(strstr($fontstyle, 'B')); $font->setItalic(strstr($fontstyle, 'I')); $font->setUnderline(strstr($fontstyle, 'U')); // armazena o objeto fonte e a cor de preenchimento $this->styles[$stylename]['font'] = $font; $this->styles[$stylename]['bgcolor'] = $fillcolor; }
function Generate_Content() { PHPRtfLite::registerAutoloader(); $largerFont = new PHPRtfLite_Font(16, 'Courier New'); $largerFont->setBold(); $smallerFont = new PHPRtfLite_Font(12, 'Times New Roman'); $tableFont = new PHPRtfLite_Font(10, 'Courier New'); //Izveido pašu dokumentu $rtf = new PHPRtfLite(); $parHead = new PHPRtfLite_ParFormat(); $parHead->setSpaceBefore(3); $parHead->setSpaceAfter(8); $parBody = new PHPRtfLite_ParFormat(); $parBody->setSpaceBefore(1); //Izveido pirmo sekciju $sect =& $rtf->addSection(); $sect->writeText("Atzīmju izraksts", $largerFont, $parHead); $sect->writeText("Skolnieks: " . $this->studentName, $smallerFont, $parHead); for ($i = 0; $i < count($this->grades); $i++) { $grade = $this->grades[$i]; $sect->writeText(sprintf("%s %s %s", $grade["date"], $grade["lesson"], $grade["grade"]), $tableFont, $parBody); } $this->fileContents = $rtf; }
/*$i = 1; foreach ($chessResults as $playerResult) { $j = 1; $sum = 0; foreach ($playerResult as $result) { if ($i != $j) { $table->writeToCell($i + 1, $j + 1, $result, new PHPRtfLite_Font(11, 'Times new Roman', '#7A2900'), new PHPRtfLite_ParFormat('center')); $sum += $result; } $j++; } $table->writeToCell($i + 1, $j + 1, '<b>'.$sum.'</b>', new PHPRtfLite_Font(11, 'Times new Roman', '#7A2900'), new PHPRtfLite_ParFormat('center')); $i++; }*/ $fontBold = new PHPRtfLite_Font(11, 'Times new Roman', '#7A2900'); $fontBold->setBold(); $table->setTextAlignmentForCellRange('center', 2, 2, $countRows, $countCols); $table->setFontForCellRange(new PHPRtfLite_Font(11, 'Times new Roman', '#7A2900'), 2, 2, $countRows, $countCols - 1); $table->setFontForCellRange($fontBold, 2, $countCols, $countRows); $table->writeToCell(1, $countCols, 'TOTAL', $font1, new PHPRtfLite_ParFormat('center')); $border = PHPRtfLite_Border::create($rtf, 1.5, '#000000'); $table->setBorderForCellRange($border, 1, $countCols, $countRows, $countCols); $borderFormat = new PHPRtfLite_Border_Format(1, '#0000ff', 'dash'); $border = new PHPRtfLite_Border($rtf, null, null, null, $borderFormat); //Registry::$debug = true; $table->setBorderForCellRange($border, 2, $countCols, $countRows - 1, $countCols); $sect->writeText('Chess tournamet play-offs (write your data)' . "\n", new PHPRtfLite_Font(14, 'Arial'), new PHPRtfLite_ParFormat()); $countSmall = 5; $countLarge = 6; $smallWidth = '0.75'; $bigWidth = ($sect->getLayoutWidth() - $countSmall * $smallWidth) / $countLarge;