/**
 * Generate the grid PDF to show the layout of the PDF.
 *
 * @param int $pageid the customcert page
 */
function customcert_generate_grid_pdf($pageid)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/pdflib.php';
    // Get the page.
    $page = $DB->get_record('customcert_pages', array('id' => $pageid), '*', MUST_EXIST);
    // Set the PDF name.
    $pdfname = get_string('gridpdfname', 'customcert', $page->id);
    // Create the pdf object.
    $pdf = new pdf();
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    $pdf->SetTitle($pdfname);
    $pdf->SetMargins(0, 0);
    $pdf->SetAutoPageBreak(true, 0);
    // Add the page to the PDF.
    if ($page->width > $page->height) {
        $orientation = 'L';
    } else {
        $orientation = 'P';
    }
    $pdf->AddPage($orientation, array($page->width, $page->height));
    // The cell width.
    $cellwidth = 10;
    $cellheight = 10;
    // The increments we want to go up in.
    $inc = 20;
    $decpos = 4;
    // Draw first lines before we increment from here.
    $pdf->Line($inc / 2 + 2, 0, $inc / 2 + 2, $page->height);
    $pdf->Line(0, $inc / 2, $page->width, $inc / 2);
    // Now we want to start drawing the lines to make the grid.
    // Draw the horizontal lines.
    for ($h = $inc; $h <= $page->height; $h += $inc) {
        // Dirty hack cause the printer keeps cutting off characters
        // near the end of the page for some BS reason.
        if (strlen($h) <= 2) {
            $lmargin = 5;
        } else {
            $lmargin = 4;
        }
        // Write the distance we are at.
        $pdf->writeHTMLCell($cellwidth, $cellheight, $lmargin, $h - $decpos, $h);
        // Get the location we are going to draw the line and then draw it.
        $hline = $h + $inc / 2;
        $pdf->Line(0, $hline, $page->width, $hline);
    }
    // Draw the vertical lines.
    for ($w = $inc; $w <= $page->width; $w += $inc) {
        // Write the distance we are at.
        $pdf->writeHTMLCell($cellwidth, $cellheight, $w - $decpos, 3, $w);
        // Get the location we are going to draw the line and then draw it.
        $wline = $w + $inc / 2;
        $pdf->Line($wline, 0, $wline, $page->height);
    }
    // Draw the margin line.
    if (!empty($page->margin)) {
        $pdf->Line($page->width - $page->margin, 0, $page->width - $page->margin, $page->height, array('dash' => '2'));
    }
    $pdf->Output($pdfname . '.pdf', 'D');
    exit;
}
 /**
  * Common behaviour for rendering specified content on the pdf.
  *
  * @param pdf $pdf the pdf object
  * @param string $content the content to render
  */
 public function render_content($pdf, $content)
 {
     list($font, $attr) = $this->get_font();
     $pdf->setFont($font, $attr, $this->element->size);
     $fontcolour = TCPDF_COLORS::convertHTMLColorToDec($this->element->colour, $fontcolour);
     $pdf->SetTextColor($fontcolour['R'], $fontcolour['G'], $fontcolour['B']);
     $x = $this->element->posx;
     $y = $this->element->posy;
     $w = $this->element->width;
     $align = $this->element->align;
     $refpoint = $this->element->refpoint;
     $actualwidth = $pdf->GetStringWidth($content);
     if ($w and $w < $actualwidth) {
         $actualwidth = $w;
     }
     switch ($refpoint) {
         case CUSTOMCERT_REF_POINT_TOPRIGHT:
             $x = $this->element->posx - $actualwidth;
             if ($x < 0) {
                 $x = 0;
                 $w = $this->element->posx;
             } else {
                 $w = $actualwidth;
             }
             break;
         case CUSTOMCERT_REF_POINT_TOPCENTER:
             $x = $this->element->posx - $actualwidth / 2;
             if ($x < 0) {
                 $x = 0;
                 $w = $this->element->posx * 2;
             } else {
                 $w = $actualwidth;
             }
             break;
     }
     if ($w) {
         $w += 0.0001;
     }
     $pdf->setCellPaddings(0, 0, 0, 0);
     $pdf->writeHTMLCell($w, 0, $x, $y, $content, 0, 0, false, true, $align);
 }
Example #3
0
$txt = get_string('memo', 'local_graduation');
$doc->Write(12, $txt, '', 0, 'C', true, 0, false, false, 20);
$linestyle = array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2', 'phase' => 0, 'color' => array(0, 0, 0));
$doc->Line(80, 30, 130, 30, $linestyle);
$doc->SetFont('times', '', 12, '', 'false');
$gradst = $DB->get_record('local_graduation', array('userid'=>$userid, 'curriculumid'=>$curid, 'programid'=>$prgid));
$gradst->userid;$gradst->programid;$gradst->curriculumid;
$table = '<table>
<tr><td style="width:100px;" align="right"><b>Student Name</b></td><td style="width:170px;"> : ' .''.$DB->get_field('user', 'firstname', array('id'=>$gradst->userid)). ' ' . $DB->get_field('user', 'lastname', array('id'=>$gradst->userid)) . '</td>
<td align="right"><b>'.get_string('studentid', 'local_graduation').'</b></td><td> : ' .''.$DB->get_field('local_userdata', 'serviceid', array('userid'=>$gradst->userid)).'</td></tr>
<tr><td align="right"><b>'.get_string('program', 'local_programs').'</b></td><td> : ' .''.$DB->get_field('local_program', 'fullname', array('id'=>$gradst->programid)).'</td>
<td align="right"><b>'.get_string('curriculum', 'local_curriculum').'</b></td><td> : ' .''.$DB->get_field('local_curriculum', 'fullname', array('id'=>$gradst->curriculumid)).'</td></tr>
<tr><td align="right"><b>'.get_string('primaryyear', 'local_admission').'</b></td><td> : ' .''.$gradst->year .'</td>
<td align="right"><b>'.get_string('final_cgpa', 'local_graduation').'</b></td><td> : ' .''.$gradst->finalcgpa .'</td></tr>
</table>';
$doc->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '35', $table, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
$stu_semsql="SELECT ls.id,ls.fullname,us.userid
				   FROM {local_user_semester} AS us
				   JOIN {local_semester} AS ls
				   ON us.semesterid=ls.id where ls.visible=1 and registrarapproval=1 and us.userid={$userid} group by ls.id";

$student_sems = $DB->get_records_sql($stu_semsql);
foreach ($student_sems as $stusem) {
	$tbl = '<table  cellpadding="2" width="460" border="0.1">';
	$tbl .= '<tr style="width:1200px;" bgcolor="#CAE1FC">';
	$tbl .= '<th style="width:150px;" align="center">'.get_string('course', 'local_cobaltcourses').'</th><th>'.get_string('maxscore', 'local_graduation').'</th><th>'.get_string('score', 'local_gradesubmission').'</th><th>'.get_string('percentage', 'local_graduation').'</th><th>'.get_string('gradeletter', 'local_gradesubmission').'</th><th align="left">'.get_string('wgp','local_graduation').'</th>';
	$tbl .= '</tr>';
	$sname = $DB->get_field('local_semester', 'fullname', array('id'=>$stusem->id));
	$semuserid = $stusem->userid;
	$clclasses = student_clclasses_grad($stusem->id, $semuserid);
	$sem_gpa = $DB->get_field('local_user_sem_details', 'gpa', array('userid'=>$semuserid, 'semesterid'=>$stusem->id));