setY(15); } // Page footer public function Footer() { $this->setY(-15); $this->SetFont('freeserif', '', 12); /*translation:Page*/ $this->Cell(0, 10, elgg_echo("koolielu:certificate_page") . ' ' . $this->getAliasNumPage() . '/'.$this->getAliasNbPages(), 0, 0, 'C'); } } // Create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($compiler_name); $pdf->SetTitle('Tiger Leap Foundation Certificate'); $pdf->SetSubject('Tiger Leap Foundation Certificate'); $pdf->SetKeywords(' '); // set 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: left, top, right $pdf->SetMargins(30, 15, 15); $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 font $pdf->SetFont('freeserif', '', 12); // add a page $pdf->AddPage(); // Header contents $pdf->Cell(0, 30, "", 0, 1, "L", 0); $pdf->Cell(0, 0, $school_name, 0, 1, "L", 0); $pdf->Cell(0, 0, $school_address, 0, 1, "L", 0); $pdf->MultiCell(120, 0, $postal_index . " " . $school_location, 0, "L", 0, 0, '', '', true ); $pdf->MultiCell(40, 0, date("m.d.Y"), 0, "R", 0, 1, '', '', true); // Main contents start $pdf->Cell(0, 20, "", 0, 1, "L", 0); /*translation:CERTIFICATE*/ $pdf->Cell(0, 0, elgg_echo("koolielu:certificate_certificate"), 0, 1, "L", 0); $pdf->Cell(0, 10, "", 0, 1, "L", 0); /*translation:Tiger Leap Foundation proves, that following learning materials have been published in Koolielu learning portal (www.koolielu.ee), the author of which is*/ $pdf->MultiCell(0, 0, elgg_echo("koolielu:certificate_maintext") . " " . get_user($user_id)->name . ":", 0, "L", 0, 1, '', '', true); $pdf->Cell(0, 5, "", 0, 1, "L", 0); // Materials part foreach ($materials_array as $key => $single_material_id) { try { $material_object = waramu_getResource("", $single_material_id); $material_moderator_id = waramu_getResourceModerator($material_object->uid); if ($material_moderator_id && !in_array($material_moderator_id, $moderators_array)) { $moderators_array[] = $material_moderator_id; } $pdf->MultiCell(0, 0, $material_object->getTitle() . " " . $CONFIG->wwwroot . "pg/waramu/view/" . $material_object->uid, 0, "L", 0, 1, '', '', true); } catch (Exception $exe) { // Waramu could not return the material, ignoring it } } // Deal with moderators $approved_by = ""; foreach($moderators_array as $key => $value) { $username = get_user($value)->name; if ($username) { if (!empty($approved_by)) $approved_by .= ", "; $approved_by .= $username; } } $pdf->Cell(0, 5, "", 0, 1, "L", 0); /*translation:Learning materials have been reviewed and published by following subject moderators of Koolielu portal*/ $pdf->MultiCell(0, 0, elgg_echo("koolielu:certificate_approved_by") . " " . $approved_by, 0, "L", 0 , 1, '', '', true); // Footer contents $pdf->Cell(0, 20, "", 0, 1, "L", 0); $pdf->Cell(0, 0, $director, 0, 1, "L", 0); /*translation:Director*/ $pdf->Cell(0, 0, elgg_echo("koolielu:certificate_director"), 0, 1, "L", 0); $pdf->Cell(0, 20, "", 0, 1, "L", 0); $pdf->Cell(0, 0, $compiler_name . " " . $compiler_phone, 0, 1, "L", 0); $pdf->Cell(0, 0, $compiler_email, 0, 1, "L", 0); // set a background color $pdf->SetFillColor(230, 240, 255, true); // Add a row to the generated certificates table koolielu_add_certificate_generated(get_loggedin_userid(), $user_id, serialize($materials_array)); // Close and output PDF document $pdf->Output('certificate.pdf', 'D'); } ?>