$doc->SetTitle('Moodle PDF library test');
 $doc->SetAuthor('Moodle ' . $CFG->release);
 $doc->SetCreator('lib/tests/other/pdflibtestpage.php');
 $doc->SetKeywords('Moodle, PDF');
 $doc->SetSubject('This has been generated by Moodle as its PDF library test page');
 $doc->SetMargins(15, 30);
 $doc->setPrintHeader(true);
 $doc->setHeaderMargin(10);
 $doc->setHeaderFont(array($fontfamily, 'b', 10));
 $doc->setHeaderData('pix/moodlelogo-med-white.gif', 40, $SITE->fullname, $CFG->wwwroot);
 $doc->setPrintFooter(true);
 $doc->setFooterMargin(10);
 $doc->setFooterFont(array($fontfamily, '', 8));
 $doc->AddPage();
 $doc->SetTextColor(255, 255, 255);
 $doc->SetFillColor(255, 203, 68);
 $doc->SetFont($fontfamily, 'B', 24);
 $doc->Cell(0, 0, 'Moodle PDF library test', 0, 1, 'C', 1);
 $doc->SetFont($fontfamily, '', 12);
 $doc->Ln(6);
 $doc->SetTextColor(0, 0, 0);
 $c = '<h3>General information</h3>';
 $c .= 'Moodle release: ' . $CFG->release . '<br />';
 $c .= 'PDF producer: TCPDF ' . TCPDF_STATIC::getTCPDFVersion() . ' (http://www.tcpdf.org) <br />';
 $c .= 'Font family used: ' . $fontfamily . '<br />';
 $c .= '<h3>Current settings</h3>';
 $c .= '<table border="1"  cellspacing="0" cellpadding="1">';
 foreach (array('K_PATH_MAIN', 'K_PATH_URL', 'K_PATH_FONTS', 'PDF_FONT_NAME_MAIN', 'K_PATH_CACHE', 'K_PATH_IMAGES', 'K_BLANK_IMAGE', 'K_CELL_HEIGHT_RATIO', 'K_SMALL_RATIO', 'PDF_CUSTOM_FONT_PATH', 'PDF_DEFAULT_FONT') as $setting) {
     if (defined($setting)) {
         $c .= '<tr style="font-size: x-small;"><td>' . $setting . '</td><td>' . constant($setting) . '</td></tr>';
     }
 /**
  * Put a QR code in cerficate pdf object
  * 
  * @param pdf $pdf The pdf object
  * @param string $code The certificate code
  */
 protected function print_qrcode($pdf, $code)
 {
     global $CFG;
     $style = array('border' => 2, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => array(255, 255, 255), 'module_width' => 1, 'module_height' => 1);
     // height of a single module in points
     $codeurl = new moodle_url("{$CFG->wwwroot}/mod/simplecertificate/verify.php");
     $codeurl->param('code', $code);
     $pdf->write2DBarcode($codeurl->out(false), 'QRCODE,M', $this->get_instance()->codex, $this->get_instance()->codey, 50, 50, $style, 'N');
     $pdf->SetXY($this->get_instance()->codex, $this->get_instance()->codey + 49);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->Cell(50, 0, $code, 'LRB', 0, 'C', true, '', 2);
 }
 $ttvlrjuros += $tvlrjuros;
 $ttvlrmulta += $tvlrmulta;
 $ttvlrdesconto += $tvlrdesconto;
 $tttotal += $ttotal;
 if ($cor == "#EFE029") {
     $cor = "#E4F471";
 } else {
     if ($cor == "#E4F471") {
         $cor = "#EFE029";
     }
 }
 if (in_array($k00_tipo, $tipos) == true) {
     if ($linha++ > $TPagina) {
         $linha = 0;
         $pdf->AddPage();
         $pdf->SetFillColor(235);
         $pdf->SetLineWidth(0.5);
         $pdf->Ln(3);
         $pdf->Cell(191, 2, '', "T", 1, "R", 0);
         $pdf->SetFont('Arial', 'B', 8);
         $pdf->Cell(25, 5, $outros3, 0, 0, "L", 0);
         $pdf->SetFont('Arial', 'I', 8);
         $pdf->Cell(80, 5, ': ' . $chave . '    ' . @$outros4, 0, 1, "L", 0);
         $pdf->SetFont('Arial', 'B', 8);
         $pdf->Cell(25, 5, "NOME", 0, 0, "L", 0);
         $pdf->SetFont('Arial', 'I', 8);
         $pdf->Cell(80, 5, ': ' . $nome, 0, 1, "L", 0);
         $pdf->SetFont('Arial', 'B', 8);
         $pdf->Cell(25, 5, "ENDEREÇO", 0, 0, "L", 0);
         $pdf->SetFont('Arial', 'I', 8);
         $pdf->Cell(80, 5, ': ' . $ender, 0, 1, "L", 0);