function generate_RTF() { global $base_path, $charset, $msg, $biblio_logo; global $biblio_name, $biblio_logo, $biblio_adr1, $biblio_adr2, $biblio_cp, $biblio_town, $biblio_state, $biblio_country, $biblio_phone, $biblio_email, $biblio_website; global $madame_monsieur; //Format des fonts $fontHead = new Font(12, 'Arial', '#0E298A'); $fontHead->setBold(); $fontSmall = new Font(1); $fontComment = new Font(10, 'Arial'); $fontComment->setItalic(); $fontChapter = new Font(10, 'Arial'); $fontSubChapter = new Font(10, 'Arial'); $fontSubChapter->setUnderline(); //Format des paragraphes $parPmb = new ParFormat(); $parPmb->setIndentRight(12.5); $parPmb->setBackColor('#0E298A'); $parPmb->setSpaceAfter(8); $parHead = new ParFormat(); $parHead->setSpaceBefore(5); $parChapter = new ParFormat(); $parChapter->setSpaceBefore(2); $parChapter->setSpaceAfter(1); $parComment = new ParFormat(); $parComment->setIndentLeft(1); $parComment->setIndentRight(0.5); $parContenu = new ParFormat('justify'); $parContenu->setIndentLeft(1); $parSubChapter = new ParFormat(); $parSubChapter->setIndentLeft(0.5); $parInfo = new ParFormat(); $parInfo->setIndentLeft(0, 5); $parInfo->setSpaceAfter(1.5); $parInfoBib = new ParFormat(); $parInfoBib->setIndentLeft(0); $parInfoBib->setSpaceAfter(1.5); //Document $rtf = new Rtf(); $rtf->setMargins(1, 1, 1, 1); foreach ($this->liste_rel as $id_fournisseur => $info_fournisseur) { $rtf->setMargins(1, 1, 1, 1); $sect =& $rtf->addSection(); $table =& $sect->addTable(); $table->addRows(1, 2); $table->addColumnsList(array(15, 4)); //$table->addImageToCell(1,1,$base_path."/images/".$biblio_logo,new ParFormat('center'),0,0); // Info biblio $cell =& $table->getCell(1, 1); $cell->writeText($this->to_utf8($biblio_name), new Font(14, 'Arial', '#0E298A'), new ParFormat('left')); if ($biblio_adr1) { $cell->writeText($this->to_utf8($biblio_adr1), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($biblio_adr2) { $cell->writeText($this->to_utf8($biblio_adr2), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($biblio_cp || $biblio_town) { $cell->writeText($this->to_utf8($biblio_cp . " " . $biblio_town), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($biblio_phone) { $cell->writeText($this->to_utf8($biblio_phone), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($biblio_email) { $cell->writeText($this->to_utf8($biblio_email), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } // Info date de génération $cell =& $table->getCell(1, 2); if ($biblio_email) { $cell->writeText($this->to_utf8("\n" . $msg['fpdf_edite'] . " " . formatdate(date("Y-m-d", time())), ENT_QUOTES, $charset), new Font(12, 'Arial', '#0E298A'), new ParFormat('right')); } if ($id_fournisseur) { $fou = new entites($id_fournisseur); $coord_fou = entites::get_coordonnees($id_fournisseur, 1); $coord_fou = pmb_mysql_fetch_object($coord_fou); if ($fou->raison_sociale != '') { $libelle = $fou->raison_sociale; } else { $libelle = $coord_fou->libelle; } $table =& $sect->addTable(); $table->addRows(2, 2); $table->addColumnsList(array(9, 10)); $cell =& $table->getCell(1, 2); $cell->writeText($this->to_utf8($libelle), new Font(14, 'Arial', '#0E298A'), new ParFormat('left')); if ($coord_fou->adr1) { $cell->writeText($this->to_utf8($coord_fou->adr1), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($coord_fou->adr2) { $cell->writeText($this->to_utf8($coord_fou->adr2), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($coord_fou->cp) { $cell->writeText($this->to_utf8($coord_fou->cp), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($coord_fou->ville) { $cell->writeText($this->to_utf8($coord_fou->ville), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } if ($coord_fou->contact != '') { $cell =& $table->getCell(2, 2); $cell->writeText($this->to_utf8($msg['acquisition_act_formule'] . " " . $coord_fou->contact), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); } } $sect->writeText($this->to_utf8($msg["abts_gestion_retard_lettre_monsieur"] . "<br />"), new Font(12, 'Arial', '#0E298A'), new ParFormat('left')); foreach ($info_fournisseur as $num_notice => $info_notice) { //print $num_notice; print_r($info_notice) ;exit; $perio = new serial_display($num_notice); $sect->writeText($this->to_utf8($perio->notice->tit1), $fontHead, $parHead); $sect->emptyParagraph($fontSmall, $parPmb); foreach ($info_notice as $abt_num => $info_abt) { //$sect->writeText($this->to_utf8($doc), new Font(10,'Arial'), $parInfo); foreach ($info_abt as $rel_id => $rel_info) { $date = "<u>" . $rel_info["rel_libelle_numero"] . "</u> : " . formatdate($rel_info["rel_date_parution"]); $sect->writeText($this->to_utf8($date), new Font(10, 'Arial'), $parInfo); $sect->writeText($this->to_utf8($rel_info["rel_comment_gestion"]), new Font(10, 'Arial'), $parSubChapter); } } } $sect->insertPageBreak(); } $rtf->sendRtf("rapport"); }
function generate_RTF() { global $msg, $base_path, $pmb_gestion_devise, $charset; //Format de la police $fontTitle = new Font(16, 'Palatino Linotype', '#0067B1'); $fontSubtitle = new Font(12, 'Palatino Linotype', '#0067B1'); $fontTabintro = new Font(12, 'Arial', '#000000'); $fontPart = new Font(11, 'Palatino Linotype', '#000000', '#E6E6E6'); $fontSubPart = new Font(9, 'Arial'); $fontSubPart->setBold(); $fontSubPart->setItalic(); $fontComment = new Font(10, 'Arial'); $fontComment->setItalic(); $fontContenu = new Font(10, 'Arial'); //Format des paragraphes $parTitle = new ParFormat('center'); $parTitle->setSpaceBefore(1.5); $parTitle->setSpaceAfter(20); $parChapter = new ParFormat('left'); $parChapter->setSpaceBefore(1); $parChapter->setSpaceAfter(1); $parSeparator = new ParFormat(); $parSeparator->setBackColor('#0067B1'); $parSeparator->setSpaceAfter(0.5); $parSeparator->setSpaceBefore(1); $parPart = new ParFormat(); $parPart->setSpaceBefore(2); $parPart->setSpaceAfter(1); $parComment = new ParFormat(); $parComment->setIndentLeft(1); $parComment->setIndentRight(0.5); $parContenu = new ParFormat('justify'); $parContenu->setIndentLeft(1); $parSubPart = new ParFormat(); $parSubPart->setIndentLeft(0.5); $rtf = new Rtf(); $rtf->setMargins(1, 1, 1, 1); $header =& $rtf->addHeader('first'); $header->addImage($base_path . '/images/logo_pmi.png', new ParFormat(), 19, 2.5); $titre_general = $this->intro[0]['TITLE'][0]['value']; $header->writeText($this->to_utf8($titre_general), $fontTitle, $parTitle); $sect =& $rtf->addSection(); $sect->writeText('Search Strategy', $fontSubtitle, $parChapter); $sect->emptyParagraph(new Font(0.5), $parSeparator); $sect->emptyParagraph(new Font(0.5), new ParFormat()); $table =& $sect->addTable(); $table->addRows(10, 0.5); $table->addColumnsList(array(4, 15)); $table->setBordersOfCells(new BorderFormat(0.5, '#000000'), 1, 1, 10, 2); $table->setVerticalAlignmentOfCells('center', 1, 1, 10, 2); $doc = $this->intro[0]['DOCUMENTALISTE'][0]['value']; $dmde = $this->intro[0]['DEMANDEUR'][0]['value']; $time = $this->intro[0]['TIME'][0]['value'] . $msg['demandes_action_time_unit']; $cout = $this->intro[0]['COST'][0]['value']; $date = $this->intro[0]['DATE'][0]['value']; $deadline = $this->intro[0]['DEADLINE'][0]['value']; $abstract = $this->intro[0]['ABSTRACT'][0]['value']; $table->writeToCell(1, 1, 'Requests', $fontTabintro, new ParFormat()); $cell =& $table->getCell(1, 2); $cell->writeText($this->to_utf8($titre_general), $fontTabintro, new ParFormat()); $table->writeToCell(2, 1, 'Searcher(s)', $fontTabintro, new ParFormat()); $cell =& $table->getCell(2, 2); $cell->writeText($this->to_utf8($doc), $fontTabintro, new ParFormat()); $table->writeToCell(3, 1, 'Patron', $fontTabintro, new ParFormat()); $cell =& $table->getCell(3, 2); $cell->writeText($this->to_utf8($dmde), $fontTabintro, new ParFormat()); $table->writeToCell(4, 1, 'Request date', $fontTabintro, new ParFormat()); $cell =& $table->getCell(4, 2); $cell->writeText($this->to_utf8($date), $fontTabintro, new ParFormat()); $table->writeToCell(5, 1, 'Deadline', $fontTabintro, new ParFormat()); $cell =& $table->getCell(5, 2); $cell->writeText($this->to_utf8($deadline), $fontTabintro, new ParFormat()); $table->writeToCell(6, 1, 'Sources', $fontTabintro, new ParFormat()); $cell =& $table->getCell(6, 2); $cell->writeText('', $fontTabintro, new ParFormat()); $table->writeToCell(7, 1, 'Keywords', $fontTabintro, new ParFormat()); $cell =& $table->getCell(7, 2); $cell->writeText('', $fontTabintro, new ParFormat()); $table->writeToCell(8, 1, 'Estimated Time for search', $fontTabintro, new ParFormat()); $cell =& $table->getCell(8, 2); $cell->writeText($this->to_utf8($time), $fontTabintro, new ParFormat()); $table->writeToCell(9, 1, 'Cost', $fontTabintro, new ParFormat()); $cell =& $table->getCell(9, 2); $cell->writeText($this->to_utf8($cout) . html_entity_decode($pmb_gestion_devise, ENT_QUOTES, 'utf-8'), $fontTabintro, new ParFormat()); $table->writeToCell(10, 1, 'Abstract', $fontTabintro, new ParFormat()); $cell =& $table->getCell(10, 2); $cell->writeText($this->to_utf8($abstract), $fontTabintro, new ParFormat()); $sect->writeText('Comments', $fontSubtitle, $parChapter); $sect->emptyParagraph(new Font(0.5), $parSeparator); $sect->emptyParagraph(new Font(0.5), new ParFormat()); $indice = 1; for ($i = 0; $i < count($this->notes); $i++) { $chapter = ""; $comment = ""; if ($this->notes[$i]['TITRE'] == 'yes') { $chapter = $this->notes[$i]['CONTENT'][0]['value']; $sect->writeText("<br>" . $indice . " - " . $this->to_utf8($chapter) . "<br>", $fontPart, $parPart); $indice++; $sujet_old = ""; } else { if ($this->notes[$i]['COMMENTAIRE'] == 'yes') { $comment = $this->notes[$i]['CONTENT'][0]['value']; $sect->writeText($this->to_utf8($comment), $fontComment, $parComment); } else { $sujet = $this->notes[$i]['SUJET'][0]['value']; $contenu = $this->notes[$i]['CONTENT'][0]['value']; if ($sujet != $sujet_old) { $sect->writeText($this->to_utf8($sujet), $fontSubPart, $parSubPart); } if ($contenu) { $sect->writeText($this->to_utf8($contenu), $fontContenu, $parContenu); } $sujet_old = $sujet; } } } $rtf->sendRtf("rapport"); }
private function handleTable(&$array) { // So sayeth the spec: ... // There is no RTF table group; instead, tables are specified as paragraph properties. // A table is represented as a sequence of table rows. A table row is a continuous sequence of paragraphs // partitioned into cells. The table row begins with the \trowd control word and ends with the \row control word. // Every paragraph that is contained in a table row must have the \intbl control word specified or inherited from // the previous paragraph. A cell may have more than one paragraph in it; the cell is terminated by a cell mark // (the \cell control word), and the row is terminated by a row mark (the \row control word). // ... // But of course, not all RTF emitters actually do this. self::$in_table = true; $widths = []; $rows = []; $gaph = 0; while ($array && $array[0] == "\\trowd") { $row = []; array_shift($array); while ($array && $array[0] != "\\row") { if ($array[0] != "\\cell" && strncmp($array[0], "\\cellx", 5) == 0) { $commands = Rtf::SplitCommand(array_shift($array)); if (isset($commands[1])) { $ws = array_sum($widths); $widths[] = $commands[1] / 20 - $ws; } } else { if (strncmp($array[0], "\\trgaph", 7) == 0) { $commands = Rtf::SplitCommand(array_shift($array)); if (isset($commands[1])) { $gaph = $commands[1] / 20; } } else { $row[] = array_shift($array); } } } array_shift($array); $columns = []; while ($row) { $column = []; while ($row && $row[0] != "\\cell") { $column[] = array_shift($row); } $columns[] = $column; array_shift($row); } $rows[] = $columns; } $num_columns = max(mapcar("count", $rows)); $row_number = 0; // Theoretically we now have an array of rows - each of which is theoretically an array of cells. $output = [$gaph ? "<table style='border-collapse: separate; border-spacing: {$gaph}pt'>" : "<table>"]; $this->pushTag("table"); $this->pushTag("tbody"); foreach ($rows as $row) { if (count($row) != $num_columns && $row_number) { $output[] = $this->popTag("tbody"); $output[] = $this->popTag("table"); $output[] = $this->pushTag("table"); $output[] = $this->pushTag("tbody"); } $output[] = $this->pushTag("tr"); foreach ($row as $cell) { $cell_contents = []; $block = new RTFBlock(); foreach ($cell as $element) { if ($element[0] != "\\") { $cell_contents[] = $block->outputText($element); } else { $cell_contents[] = $block->getHTML([$element]); } } $width = array_shift($widths); $cell_contents[] = $block->endOutput(); $contents = join("", flatten($cell_contents)); // it would be cleaner to do this with classes, but we can't guarantee that CSS classes are going to be // available because we're intentionally not emitting a full HTML document. But since we really only care // about right alignment, let's hack in a cell-wide alignment if some of the cell text is right-aligned. // Of course this will fail 'orribly if some of the cell text is also supposed to _not_ be so aligned. $block->pushTag("td"); $output[] = "<td style='vertical-align: top; padding: 0.25em; " . ($width ? " width: {$width}pt;" : "") . (strpos($contents, "text-align: right") !== false ? " text-align: right;" : "") . "'>"; $output[] = $contents; $output[] = $block->popTag("td"); } $output[] = $this->popTag("tr"); $row_number++; if (count($row) != $num_columns && $row_number != count($rows)) { $output[] = $this->popTag("tbody"); $output[] = $this->popTag("table"); $output[] = $this->pushTag("table"); $output[] = $this->pushTag("tbody"); } } $output[] = $this->popTag("tbody"); $output[] = $this->popTag("table"); self::$in_table = false; return $output; }
/** * Gets rtf code of font. Internal use. * @param Rtf $rtf Rtf object * @return string * @access public */ function getContent(&$rtf) { $content = !empty($this->size) ? '\\fs' . $this->size * 2 . ' ' : ''; if (!empty($this->font)) { $rtf->addFont($this->font); $content .= $rtf->GetFont($this->font) . ' '; } if (!empty($this->fontColor)) { $rtf->addColor($this->fontColor); $content .= $rtf->GetFontColor($this->fontColor) . ' '; } if (!empty($this->backColor)) { $rtf->addColor($this->backColor); $content .= $rtf->GetBackColor($this->backColor) . ' '; } $content .= !empty($this->bold) ? '\\b ' : ''; $content .= !empty($this->italic) ? '\\i ' : ''; $content .= !empty($this->underline) ? '\\ul ' : ''; $content .= !empty($this->animatedText) ? '\\animtext' . $this->animatedText : ''; $content .= !empty($this->strike) ? '\\strike ' . $this->animatedText : ''; $content .= !empty($this->strikeDouble) ? '\\striked1 ' . $this->animatedText : ''; return $content; }