/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { $colour = TCPDF_COLORS::convertHTMLColorToDec($this->element->colour, $colour); $pdf->SetLineStyle(array('width' => $this->element->data, 'color' => $colour)); $pdf->Line(0, 0, $pdf->getPageWidth(), 0); $pdf->Line($pdf->getPageWidth(), 0, $pdf->getPageWidth(), $pdf->getPageHeight()); $pdf->Line(0, $pdf->getPageHeight(), $pdf->getPageWidth(), $pdf->getPageHeight()); $pdf->Line(0, 0, 0, $pdf->getPageHeight()); }
/** * Refactored code from @see certificate_output_completion() * an array of parameters is passed and used by the certificate * template file. It is up to the certificate template file to * use whatever parameters are available * * @param array $params: An array of parameters (example: array('student_name' => 'some value')) * Here are a list of values that can be used * 'student_name', 'course_name', 'class_idnumber', 'class_enrol_time', 'class_enddate', 'class_grade', * 'cert_timeissued', 'cert_code', 'class_instructor_name', 'course_description_name' * (there will most likely be more when other entity types are added) * @param string $border: A custom border image to use * @param string $seal: A custom seal image to use * @param string $template: A custom template to use * @return string - pdf output */ function certificate_output_entity_completion($params, $border = '', $seal = '', $template = '') { global $CFG; // Use the TCPDF library. require_once $CFG->libdir . '/pdflib.php'; // Global settings. $borders = 0; $font = 'FreeSerif'; $largefontsize = 30; $smallfontsize = 16; // Create pdf. $pdf = new pdf('L', 'in', 'Letter'); // Prevent the pdf from printing black bars. $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetAutoPageBreak(false); $pdf->SetMargins(0, 0, 0, false); $pdf->AddPage(); $pagewidth = $pdf->getPageWidth(); $pageheight = $pdf->getPageHeight(); // Draw the border. cm_certificate_check_data_path('borders'); if (!empty($border)) { if (file_exists($CFG->dirroot . '/local/elisprogram/pix/certificate/borders/' . $border)) { $pdf->Image($CFG->dirroot . '/local/elisprogram/pix/certificate/borders/' . $border, 0, 0, $pagewidth, $pageheight); } else { if (file_exists($CFG->dataroot . '/local/elisprogram/pix/certificate/borders/' . $border)) { $pdf->Image($CFG->dataroot . '/local/elisprogram/pix/certificate/borders/' . $border, 0, 0, $pagewidth, $pageheight); } } } // Draw the seal. cm_certificate_check_data_path('seals'); if (!empty($seal)) { if (file_exists($CFG->dirroot . '/local/elisprogram/pix/certificate/seals/' . $seal)) { $pdf->Image($CFG->dirroot . '/local/elisprogram/pix/certificate/seals/' . $seal, 8.0, 5.8); } else { if (file_exists($CFG->dataroot . '/local/elisprogram/pix/certificate/seals/' . $seal)) { $pdf->Image($CFG->dataroot . '/local/elisprogram/pix/certificate/seals/' . $seal, 8.0, 5.8); } } } // Include the certificate template. cm_certificate_check_data_path('templates'); if (file_exists($CFG->dirroot . '/local/elisprogram/pix/certificate/templates/' . $template)) { include $CFG->dirroot . '/local/elisprogram/pix/certificate/templates/' . $template; } else { if (file_exists($CFG->dataroot . '/local/elisprogram/pix/certificate/templates/' . $template)) { include $CFG->dataroot . '/local/elisprogram/pix/certificate/templates/' . $template; } } $pdf->Output(); }