} else { $credithours = ''; } //Print the html text $customtext = $certificate->customtext; //Add pdf page $orientation = "L"; $pdf = new PDF($orientation, 'pt', 'A4'); $pdf->SetProtection(array('print')); $pdf->AddPage(); if (ini_get('magic_quotes_gpc') == '1') { $customtext = stripslashes($customtext); } // Add images and lines print_border($certificate->borderstyle, $orientation); draw_frame($certificate->bordercolor, $orientation); print_watermark($certificate->printwmark, $orientation); print_seal($certificate->printseal, $orientation, 590, 425, '', ''); print_signature($certificate->printsignature, $orientation, 130, 440, '', ''); // Add text $pdf->SetTextColor(0, 0, 120); cert_printtext(170, 125, 'C', 'Helvetica', 'B', 30, utf8_decode(get_string('titlelandscape', 'certificate'))); $pdf->SetTextColor(0, 0, 0); cert_printtext(170, 180, 'C', 'Times', 'B', 20, utf8_decode(get_string('introlandscape', 'certificate'))); cert_printtext(170, 230, 'C', 'Helvetica', '', 30, utf8_decode($studentname)); cert_printtext(170, 280, 'C', 'Helvetica', '', 20, utf8_decode(get_string('statementlandscape', 'certificate'))); cert_printtext(170, 330, 'C', 'Helvetica', '', 20, utf8_decode($classname)); cert_printtext(170, 380, 'C', 'Helvetica', '', 14, utf8_decode($certificatedate)); cert_printtext(170, 420, 'C', 'Times', '', 10, utf8_decode($grade)); cert_printtext(170, 431, 'C', 'Times', '', 10, utf8_decode($outcome)); cert_printtext(170, 442, 'C', 'Times', '', 10, utf8_decode($credithours));
$sigy = 230; $custx = 30; $custy = 230; $wmarkx = 26; $wmarky = 58; $wmarkw = 158; $wmarkh = 170; $brdrx = 0; $brdry = 0; $brdrw = 210; $brdrh = 297; $codey = 250; } // Add images and lines print_border($pdf, $certificate, $brdrx, $brdry, $brdrw, $brdrh); draw_frame($pdf, $certificate); // Set alpha to semi-transparency $pdf->SetAlpha(0.2); print_watermark($pdf, $certificate, $wmarkx, $wmarky, $wmarkw, $wmarkh); $pdf->SetAlpha(1); print_seal($pdf, $certificate, $sealx, $sealy, '', ''); print_signature($pdf, $certificate, $sigx, $sigy, '', ''); // Add text $pdf->SetTextColor(0, 0, 120); cert_printtext($pdf, $x, $y, 'C', 'freesans', '', 30, get_string('title', 'certificate')); $pdf->SetTextColor(0, 0, 0); cert_printtext($pdf, $x, $y + 20, 'C', 'freeserif', '', 20, get_string('certify', 'certificate')); cert_printtext($pdf, $x, $y + 36, 'C', 'freesans', '', 30, $studentname); cert_printtext($pdf, $x, $y + 55, 'C', 'freesans', '', 20, get_string('statement', 'certificate')); cert_printtext($pdf, $x, $y + 72, 'C', 'freesans', '', 20, $classname); cert_printtext($pdf, $x, $y + 92, 'C', 'freesans', '', 14, $certificatedate);
function print_border($border, $color, $orientation) { global $CFG, $pdf; switch ($border) { case '0': break; case '1': draw_frame($color, $orientation); break; default: switch ($orientation) { case 'L': if (file_exists("{$CFG->dirroot}/mod/certificate/pix/borders/{$border}-{$color}.jpg")) { $pdf->Image("{$CFG->dirroot}/mod/certificate/pix/borders/{$border}-{$color}.jpg", 10, 10, 820, 580); } break; case 'P': if (file_exists("{$CFG->dirroot}/mod/certificate/pix/borders/{$border}-{$color}.jpg")) { $pdf->Image("{$CFG->dirroot}/mod/certificate/pix/borders/{$border}-{$color}.jpg", 10, 10, 580, 820); } break; } break; } }