public static function renderAnswer($answer) { require_once Yii::getPathOfAlias('application.vendor') . '/tcpdf/tcpdf.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setPDFVersion('1.7'); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Biobanques'); $pdf->SetTitle($answer->name); $pdf->SetSubject($answer->name); $pdf->SetKeywords('Biobanques, PDF, cbsd, platform' . $answer->name); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) /* if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once(dirname(__FILE__) . '/lang/eng.php'); $pdf->setLanguageArray($l); } */ // --------------------------------------------------------- // IMPORTANT: disable font subsetting to allow users editing the document $pdf->setFontSubsetting(false); // set font $pdf->SetFont('helvetica', '', 8, '', false); // add a page $pdf->AddPage(); //form default properties $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => "lightGray", 'strokeColor' => "gray")); $pdf->SetFont('helvetica', 'B', 18); $pdf->Cell(0, 5, 'Biobanques CBSDPlatform ', 0, 1, 'C'); $pdf->Ln(10); $pdf->Cell(0, 5, $answer->name, 0, 1, 'C'); $pdf->Ln(10); $pdf->Cell(0, 5, "-", 0, 1, 'C'); $pdf->Ln(10); $pdf->Cell(0, 5, $answer->name, 0, 1, 'C'); $pdf->Ln(30); $pdf->SetFont('helvetica', 'N', 12); $dd = $answer->last_modified['date']; //mongo date $html = '<span>' . "<b>Description :</b> " . $answer->description . '<br /><b>Dernière modification : </b>' . date("d/m/Y H:i", strtotime($dd)) . '</span>'; $pdf->writeHTMLCell(0, 0, '', '', $html, 1, 1, false, true, '', false); $pdf->Ln(10); $pdf = AnswerPDFRenderer::renderAnsweredPDF($pdf, $answer, "fr"); // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('biobanques_cbsdplatform_' . $answer->id . '.pdf', 'D'); }