/** * tests getContent(). */ public function testGetContent() { $this->_parFormat->setIndentLeft(5); $this->_parFormat->setIndentRight(5); $this->_parFormat->setSpaceBefore(5); $this->_parFormat->setSpaceAfter(5); $this->_parFormat->setIndentFirstLine(3); $this->_parFormat->setSpaceBetweenLines(1.2); $this->_parFormat->setShading(50); $this->assertEquals('\\ql \\fi1701 \\li2835 \\ri2835 \\sb100 \\sa100 \\sl288 \\shading5000 ', $this->_parFormat->getContent()); }
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; }
// Добавить футер $footer = $rtf->addFooter(); $fontFooter = new PHPRtfLite_Font(8, 'Arial', '#000000'); $alignFooter = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER); $footer->writeText('Used cars for sale - <pagenum>', $fontFooter, $alignFooter); // Определить шрифты $fontH1 = new PHPRtfLite_Font(16, 'Arial', '#4E9C93'); $fontH2 = new PHPRtfLite_Font(14, 'Arial', '#4E9C93'); $fontP = new PHPRtfLite_Font(12, 'Helvetica', '#000000'); // Вертикальное форматирование текста $formatH1 = new PHPRtfLite_ParFormat(); $formatH1->setSpaceAfter(8); $formatH2 = new PHPRtfLite_ParFormat(); $formatH2->setSpaceAfter(6); $formatP = new PHPRtfLite_ParFormat(); $formatP->setSpaceAfter(3); // Содержание страницы $section = $rtf->addSection(); $section->writeText('Used Cars for Sale', $fontH1, $formatH1); while ($row = getRow($result)) { $section->writeText($row['make'], $fontH2, $formatH2); $section->setNoBreak(); $section->writeText('<bullet> Price: $' . number_format($row['price'], 2), $fontP, $formatP); $section->writeText('<bullet> Mileage: ' . number_format($row['mileage']), $fontP, $formatP); $section->writeText('<bullet> Transmission: ' . $row['transmission'], $fontP, $formatP); $section->writeText($row['description'] . '<hr>', $fontP, $formatP); } // Выходной файл $rtf->sendRtf('cars.rtf'); } catch (Exception $e) { $error = $e->getMessage();
$sect = $rtf->addSection(); // *** RTF Settings *** $arial12 = new PHPRtfLite_Font(12, 'Arial'); $arial14 = new PHPRtfLite_Font(14, 'Arial', '#000066'); //Fonts $fontHead = new PHPRtfLite_Font(12, 'Arial'); $fontSmall = new PHPRtfLite_Font(3); $fontAnimated = new PHPRtfLite_Font(10); $fontLink = new PHPRtfLite_Font(10, 'Helvetica', '#0000cc'); $parBlack = new PHPRtfLite_ParFormat(); $parBlack->setIndentRight(12.5); //$parBlack->setBackgroundColor('#000000'); $parBlack->setSpaceBefore(12); $parHead = new PHPRtfLite_ParFormat(); $parHead->setSpaceBefore(3); $parHead->setSpaceAfter(8); $parHead->setBackgroundColor('#baf4c1'); $parSimple = new PHPRtfLite_ParFormat(); $parSimple->setIndentLeft(1); $parSimple->setIndentRight(0.5); $par_child_text = new PHPRtfLite_ParFormat(); $par_child_text->setIndentLeft(0.5); $par_child_text->setIndentRight(0.5); //$rtf->setMargins(3, 1, 1 ,2); // *** Generate title of RTF file *** @($persDb = $db_functions->get_person($main_person)); // *** Use class to process person *** $pers_cls = new person_cls(); $pers_cls->construct($persDb); $name = $pers_cls->person_name($persDb); if (!$descendant_report == false) {
// *** Add section *** $sect = $rtf->addSection(); // *** RTF Settings *** $arial10 = new PHPRtfLite_Font(10, 'Arial'); $arial12 = new PHPRtfLite_Font(12, 'Arial'); $arial14 = new PHPRtfLite_Font(14, 'Arial', '#000066'); //Fonts $fontHead = new PHPRtfLite_Font(12, 'Arial'); $fontSmall = new PHPRtfLite_Font(3); $fontAnimated = new PHPRtfLite_Font(10); $fontLink = new PHPRtfLite_Font(10, 'Helvetica', '#0000cc'); $parNames = new PHPRtfLite_ParFormat(); $parNames->setBackgroundColor('#FFFFFF'); $parNames->setIndentLeft(0); $parNames->setSpaceBefore(0); $parNames->setSpaceAfter(0); $parHead = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER); $parHead->setSpaceBefore(3); $parHead->setSpaceAfter(8); $parHead->setBackgroundColor('#baf4c1'); $parGen = new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER); $parGen->setSpaceBefore(0); $parGen->setSpaceAfter(8); $parGen->setBackgroundColor('#baf4c1'); $parSimple = new PHPRtfLite_ParFormat(); $parSimple->setIndentLeft(2.5); $parSimple->setIndentRight(0.5); // *** Generate title of RTF file *** $pers = $dbh->query("SELECT * FROM humo_persons WHERE pers_tree_id='" . $tree_id . "' AND pers_gedcomnumber='{$family_id}'"); @($persDb = $pers->fetch(PDO::FETCH_OBJ)); // *** Use person class ***