/** * 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()); }
$pdf->CreateTextBox($user->email, 0, 60, 80, 10, 10); $pdf->CreateTextBox($user->phone, 0, 65, 80, 10, 10); //$pdf->CreateTextBox('Zip, city name', 0, 70, 80, 10, 10); // invoice title / number $pdf->CreateTextBox('Factura #' . $booking->id, 0, 90, 120, 20, 16); // date, order ref $date = date_create($booking->date_booking); $pdf->CreateTextBox('Fecha: ' . date_format($date, "d/m/Y H:i:s"), 0, 100, 0, 10, 10, '', 'R'); $pdf->CreateTextBox('Order ref.: #' . $booking->id, 0, 105, 0, 10, 10, '', 'R'); // ROWS // list headers $pdf->CreateTextBox('Dias', 0, 120, 20, 10, 10, 'B', 'C'); $pdf->CreateTextBox('Habitacion', 20, 120, 90, 10, 10, 'B'); $pdf->CreateTextBox('Precio', 110, 120, 30, 10, 10, 'B', 'R'); $pdf->CreateTextBox('Total', 140, 120, 30, 10, 10, 'B', 'R'); $pdf->Line(20, 129, 195, 129); $currY = 128; $pdf->CreateTextBox($booking->getDays(), 0, $currY, 20, 10, 10, '', 'C'); $pdf->CreateTextBox($room->name, 20, $currY, 90, 10, 10, ''); $pdf->CreateTextBox('€' . $room->price, 110, $currY, 30, 10, 10, '', 'R'); $pdf->CreateTextBox('€' . $booking->getTotal(), 140, $currY, 30, 10, 10, '', 'R'); $currY = $currY + 5; $pdf->Line(20, $currY + 4, 195, $currY + 4); // FOOTER // output the total row $pdf->CreateTextBox('Total', 20, $currY + 5, 135, 10, 10, 'B', 'R'); $pdf->CreateTextBox('€' . number_format($booking->getTotal(), 2, '.', ''), 140, $currY + 5, 30, 10, 10, 'B', 'R'); // some payment instructions or information $pdf->setXY(20, $currY + 30); $pdf->SetFont(PDF_FONT_NAME_MAIN, '', 10); $pdf->MultiCell(175, 10, '<em>Lorem ipsum dolor sit amet, consectetur adipiscing elit</em>.
/** * 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; }
$userid = optional_param ('userid', 0, PARAM_INT); $prgid = optional_param ('prgid', 0, PARAM_INT); $year = optional_param ('year', 0, PARAM_INT); ob_clean() ; require_once($CFG->dirroot.'/lib/pdflib.php'); $doc = new pdf; $doc->setPrintHeader(false); $doc->setPrintFooter(false); $doc->AddPage(); $doc->SetFont('times', 'B', 25, '', 'false'); $gradst = $DB->get_record('local_graduation', array('userid'=>$userid, 'curriculumid'=>$curid, 'programid'=>$prgid)); $txt = $DB->get_field('local_school', 'fullname', array('id'=>$gradst->schoolid)); $doc->Write(0, $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(10, 22, 200, 22, $linestyle); $doc->SetFont('times', 'BI', 14, '', 'false'); $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>