本文整理汇总了PHP中pdf::Output方法的典型用法代码示例。如果您正苦于以下问题:PHP pdf::Output方法的具体用法?PHP pdf::Output怎么用?PHP pdf::Output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pdf
的用法示例。
在下文中一共展示了pdf::Output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generar
/**
*
* @param int $id_emergencia
*/
public function generar($id_emergencia, $mapa = true, $codigo)
{
$emergencia = $this->_ci->emergencia_model->getById($id_emergencia);
if (!is_null($emergencia)) {
$data = array("eme_ia_id" => $emergencia->eme_ia_id, "eme_c_nombre_emergencia" => $emergencia->eme_c_nombre_emergencia, "eme_c_nombre_informante" => $emergencia->eme_c_nombre_informante, "eme_d_fecha_emergencia" => ISODateTospanish($emergencia->eme_d_fecha_emergencia, false), "hora_emergencia" => ISOTimeTospanish($emergencia->eme_d_fecha_emergencia), "hora_recepcion" => ISOTimeTospanish($emergencia->eme_d_fecha_recepcion), "eme_c_lugar_emergencia" => $emergencia->eme_c_lugar_emergencia, "emisor" => $this->_ci->session->userdata('session_nombres'), "id_usuario_encargado" => $emergencia->usu_ia_id, "eme_c_descripcion" => $emergencia->eme_c_descripcion, "est_ia_id" => $emergencia->est_ia_id, "tip_ia_id" => $emergencia->tip_ia_id);
$datos = unserialize($emergencia->eme_c_datos_tipo_emergencia);
foreach ($datos as $key => $value) {
$data['form_tipo_' . $key] = $value;
}
}
$data['codigo'] = $codigo;
$data['region'] = '';
$regiones = explode(',', $this->_ci->session->userdata('session_regiones'));
if (count($regiones) == 1) {
if ($regiones[0] == 13) {
$data['region'] = 'RM';
} else {
$data['region'] = $regiones[0] . 'º';
}
}
$data['cargo'] = $this->_ci->session->userdata('session_cargo');
$data['mapa'] = $mapa;
$html = $this->_ci->load->view('pages/emergencia_reporte/pdf', $data, true);
$this->_pdf->imagen_mapa = $this->_imagen;
$this->_pdf->imagen_logo = file_get_contents(FCPATH . "/assets/img/top_logo.png");
$this->_pdf->SetFooter($_SERVER['HTTP_HOST'] . '|{PAGENO}/{nb}|' . date('d-m-Y H:i'));
$this->_pdf->WriteHTML($html);
return $this->_pdf->Output('acta.pdf', 'S');
}
示例2: pdf
function report_download_pdf($html)
{
$doc = new pdf();
//$doc->Header();
$doc->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, 'Teleparadigm', array(), array());
$doc->setFooterData(array(0, 64, 0), array(0, 64, 128));
$doc->setPrintHeader(false);
$doc->setPrintFooter(true);
// set margins
$doc->SetMargins(PDF_MARGIN_LEFT, 5, PDF_MARGIN_RIGHT);
$doc->SetHeaderMargin(PDF_MARGIN_HEADER);
$doc->SetFooterMargin(PDF_MARGIN_FOOTER);
$doc->AddPage();
$doc->writeHTML($html, true, false, true, false, '');
$doc->Output();
die;
}
示例3: certificate_output_completion
/**
* Outputs a certificate for some sort of completion element
*
* @param string $person_fullname The full name of the certificate recipient
* @param string $entity_name The name of the entity that is compelted
* @param string $certificatecode The unique certificate code
* @param string $date_string Date /time the certification was achieved
* @param string $curriculum_frequency the curriculum frequency
* @param string $expirydate A string representing the time that the
* certificate expires (optional).
*/
function certificate_output_completion($person_fullname, $entity_name, $certificatecode = '', $date_string, $expirydate = '', $curriculum_frequency = '', $border = '', $seal = '', $template = '')
{
global $CFG, $COURSE;
//use the TCPDF library
require_once $CFG->libdir . '/pdflib.php';
//global settings
$borders = 0;
$font = 'FreeSerif';
$large_font_size = 30;
$small_font_size = 16;
//create pdf
$pdf = new pdf('L', 'in', 'Letter');
//prevent the pdf from printing black bars
$pdf->print_header = false;
$pdf->print_footer = false;
//add main (only) page
$pdf->AddPage();
//draw the border
cm_certificate_check_data_path('borders');
if (file_exists($CFG->dirroot . '/curriculum/pix/certificate/borders/' . $border)) {
$pdf->Image($CFG->dirroot . '/curriculum/pix/certificate/borders/' . $border, 0.25, 0.25, 10.5, 8.0);
} else {
if (file_exists($CFG->dataroot . '/' . $COURSE->id . '/curriculum/pix/certificate/borders/' . $border)) {
$pdf->Image($CFG->dataroot . '/' . $COURSE->id . '/curriculum/pix/certificate/borders/' . $border, 0.25, 0.25, 10.5, 8.0);
}
}
//draw the seal
cm_certificate_check_data_path('seals');
if (file_exists($CFG->dirroot . '/curriculum/pix/certificate/seals/' . $seal)) {
$pdf->Image($CFG->dirroot . '/curriculum/pix/certificate/seals/' . $seal, 8.0, 5.8);
} else {
if (file_exists($CFG->dataroot . '/' . $COURSE->id . '/curriculum/pix/certificate/seals/' . $seal)) {
$pdf->Image($CFG->dataroot . '/' . $COURSE->id . '/curriculum/pix/certificate/seals/' . $seal, 8.0, 5.8);
}
}
//include template
cm_certificate_check_data_path('templates');
if (file_exists($CFG->dirroot . '/curriculum/pix/certificate/templates/' . $template)) {
include $CFG->dirroot . '/curriculum/pix/certificate/templates/' . $template;
} else {
if (file_exists($CFG->dataroot . '/' . $COURSE->id . '/curriculum/pix/certificate/templates/' . $template)) {
include $CFG->dirroot . '/curriculum/pix/certificate/templates/' . $template;
}
}
$pdf->Output();
}
示例4: actionView
//.........这里部分代码省略.........
$thissurvey = getSurveyInfo($surveyid, $language);
//SET THE TEMPLATE DIRECTORY
if (!isset($thissurvey['templatedir']) || !$thissurvey['templatedir']) {
$thistpl = validateTemplateDir("default");
} else {
$thistpl = validateTemplateDir($thissurvey['templatedir']);
}
if ($thissurvey['printanswers'] == 'N') {
die;
//Die quietly if print answers is not permitted
}
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
$surveytable = "{{survey_{$surveyid}}}";
$surveyname = $thissurvey['surveyls_title'];
$anonymized = $thissurvey['anonymized'];
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$printoutput = '';
$printoutput .= "<form action='" . Yii::app()->getController()->createUrl('printanswers/view/surveyid/' . $surveyid . '/printableexport/pdf') . "' method='post'>\n<center><input type='submit' value='" . $clang->gT("PDF export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
if ($printableexport == 'pdf') {
require Yii::app()->getConfig('rootdir') . '/application/config/tcpdf.php';
Yii::import('application.libraries.admin.pdf', true);
$pdf = new pdf();
$pdf->setConfig($tcpdf);
//$pdf->SetFont($pdfdefaultfont,'',$pdffontsize);
$pdf->AddPage();
//$pdf->titleintopdf($clang->gT("Survey name (ID)",'unescaped').": {$surveyname} ({$surveyid})");
$pdf->SetTitle($clang->gT("Survey name (ID)", 'unescaped') . ": {$surveyname} ({$surveyid})");
}
$printoutput .= "\t<div class='printouttitle'><strong>" . $clang->gT("Survey name (ID):") . "</strong> {$surveyname} ({$surveyid})</div><p> \n";
LimeExpressionManager::StartProcessingPage(true);
// means that all variables are on the same page
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
LimeExpressionManager::StartProcessingGroup(1, $thissurvey['anonymized'] != "N", $surveyid);
$aFullResponseTable = getFullResponseTable($surveyid, $id, $language, true);
//Get the fieldmap @TODO: do we need to filter out some fields?
unset($aFullResponseTable['id']);
unset($aFullResponseTable['token']);
unset($aFullResponseTable['lastpage']);
unset($aFullResponseTable['startlanguage']);
unset($aFullResponseTable['datestamp']);
unset($aFullResponseTable['startdate']);
$printoutput .= "<table class='printouttable' >\n";
if ($printableexport == 'pdf') {
$pdf->intopdf($clang->gT("Question", 'unescaped') . ": " . $clang->gT("Your answer", 'unescaped'));
}
$oldgid = 0;
$oldqid = 0;
foreach ($aFullResponseTable as $sFieldname => $fname) {
if (substr($sFieldname, 0, 4) == 'gid_') {
if ($printableexport) {
$pdf->intopdf(flattenText($fname[0], false, true));
$pdf->ln(2);
} else {
$printoutput .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
}
} elseif (substr($sFieldname, 0, 4) == 'qid_') {
if ($printableexport == 'pdf') {
$pdf->intopdf(flattenText($fname[0] . $fname[1], false, true) . ": " . $fname[2]);
$pdf->ln(2);
} else {
$printoutput .= "\t<tr class='printanswersquestionhead'><td colspan='2'>{$fname[0]}</td></tr>\n";
}
} elseif ($sFieldname == 'submitdate') {
if ($anonymized != 'Y') {
if ($printableexport == 'pdf') {
$pdf->intopdf(flattenText($fname[0] . $fname[1], false, true) . ": " . $fname[2]);
$pdf->ln(2);
} else {
$printoutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]} {$sFieldname}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
}
}
} else {
if ($printableexport == 'pdf') {
$pdf->intopdf(flattenText($fname[0] . $fname[1], false, true) . ": " . $fname[2]);
$pdf->ln(2);
} else {
$printoutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
}
}
}
$printoutput .= "</table>\n";
if ($printableexport == 'pdf') {
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$sExportFileName = sanitize_filename($surveyname);
$pdf->Output($sExportFileName . "-" . $surveyid . ".pdf", "D");
}
//Display the page with user answers
if (!$printableexport) {
sendCacheHeaders();
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($thistpl) . '/startpage.pstpl'));
echo templatereplace(file_get_contents(getTemplatePath($thistpl) . '/printanswers.pstpl'), array('ANSWERTABLE' => $printoutput));
echo templatereplace(file_get_contents(getTemplatePath($thistpl) . '/endpage.pstpl'));
echo "</body></html>";
}
LimeExpressionManager::FinishProcessingGroup();
LimeExpressionManager::FinishProcessingPage();
}
示例5: generate_combined_pdf_for_attempt
/**
* This function will take all of the compatible files for a submission
* and combine them into one PDF.
* @param int|\assign $assignment
* @param int $userid
* @param int $attemptnumber (-1 means latest attempt)
* @return stored_file
*/
public static function generate_combined_pdf_for_attempt($assignment, $userid, $attemptnumber)
{
global $CFG;
require_once $CFG->libdir . '/pdflib.php';
$assignment = self::get_assignment_from_param($assignment);
if (!$assignment->can_view_submission($userid)) {
\print_error('nopermission');
}
$files = self::list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber);
$pdf = new pdf();
if (!$files) {
// No valid submission files - create an empty pdf.
$pdf->AddPage();
} else {
// Create a mega joined PDF.
$compatiblepdfs = array();
foreach ($files as $file) {
$compatiblepdf = pdf::ensure_pdf_compatible($file);
if ($compatiblepdf) {
array_push($compatiblepdfs, $compatiblepdf);
}
}
$tmpdir = \make_temp_directory('assignfeedback_editpdf/combined/' . self::hash($assignment, $userid, $attemptnumber));
$tmpfile = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
@unlink($tmpfile);
try {
$pagecount = $pdf->combine_pdfs($compatiblepdfs, $tmpfile);
} catch (\Exception $e) {
debugging('TCPDF could not process the pdf files:' . $e->getMessage(), DEBUG_DEVELOPER);
// TCPDF does not recover from errors so we need to re-initialise the class.
$pagecount = 0;
}
if ($pagecount == 0) {
// We at least want a single blank page.
debugging('TCPDF did not produce a valid pdf:' . $tmpfile . '. Replacing with a blank pdf.', DEBUG_DEVELOPER);
$pdf = new pdf();
$pdf->AddPage();
@unlink($tmpfile);
$files = false;
}
}
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdf';
$record->filearea = self::COMBINED_PDF_FILEAREA;
$record->itemid = $grade->id;
$record->filepath = '/';
$record->filename = self::COMBINED_PDF_FILENAME;
$fs = \get_file_storage();
$fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid);
// Detect corrupt generated pdfs and replace with a blank one.
if ($files) {
$pagecount = $pdf->load_pdf($tmpfile);
if ($pagecount <= 0) {
$files = false;
}
}
if (!$files) {
// This was a blank pdf.
unset($pdf);
$pdf = new pdf();
$content = $pdf->Output(self::COMBINED_PDF_FILENAME, 'S');
$file = $fs->create_file_from_string($record, $content);
} else {
// This was a combined pdf.
$file = $fs->create_file_from_pathname($record, $tmpfile);
@unlink($tmpfile);
// Test the generated file for correctness.
$compatiblepdf = pdf::ensure_pdf_compatible($file);
}
return $file;
}
示例6: actionView
/**
* printanswers::view()
* View answers at the end of a survey in one place. To export as pdf, set 'usepdfexport' = 1 in lsconfig.php and $printableexport='pdf'.
* @param mixed $surveyid
* @param bool $printableexport
* @return
*/
function actionView($surveyid, $printableexport = FALSE)
{
Yii::app()->loadHelper("frontend");
Yii::import('application.libraries.admin.pdf');
$iSurveyID = (int) $surveyid;
$sExportType = $printableexport;
Yii::app()->loadHelper('database');
if (isset($_SESSION['survey_' . $iSurveyID]['sid'])) {
$iSurveyID = $_SESSION['survey_' . $iSurveyID]['sid'];
} else {
//die('Invalid survey/session');
}
// Get the survey inforamtion
// Set the language for dispay
if (isset($_SESSION['survey_' . $iSurveyID]['s_lang'])) {
$sLanguage = $_SESSION['survey_' . $iSurveyID]['s_lang'];
} elseif (Survey::model()->findByPk($iSurveyID)) {
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$iSurveyID = 0;
$sLanguage = Yii::app()->getConfig("defaultlang");
}
SetSurveyLanguage($iSurveyID, $sLanguage);
$aSurveyInfo = getSurveyInfo($iSurveyID, $sLanguage);
$oTemplate = Template::model()->getInstance(null, $iSurveyID);
//Survey is not finished or don't exist
if (!isset($_SESSION['survey_' . $iSurveyID]['finished']) || !isset($_SESSION['survey_' . $iSurveyID]['srid'])) {
sendCacheHeaders();
doHeader();
/// $oTemplate is a global variable defined in controller/survey/index
echo templatereplace(file_get_contents($oTemplate->viewPath . '/startpage.pstpl'), array());
echo "<center><br />\n" . "\t<font color='RED'><strong>" . gT("Error") . "</strong></font><br />\n" . "\t" . gT("We are sorry but your session has expired.") . "<br />" . gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.") . "<br />\n" . "\t" . sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")) . "\n" . "</center><br />\n";
echo templatereplace(file_get_contents($oTemplate->viewPath . '/endpage.pstpl'), array());
doFooter();
exit;
}
//Fin session time out
$sSRID = $_SESSION['survey_' . $iSurveyID]['srid'];
//I want to see the answers with this id
//Ensure script is not run directly, avoid path disclosure
//if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die( "browse - Cannot run this script directly");}
//Ensure Participants printAnswer setting is set to true or that the logged user have read permissions over the responses.
if ($aSurveyInfo['printanswers'] == 'N' && !Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
throw new CHttpException(401, 'You are not allowed to print answers.');
}
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
$sSurveyName = $aSurveyInfo['surveyls_title'];
$sAnonymized = $aSurveyInfo['anonymized'];
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
if ($sExportType != 'pdf') {
$sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post') . "<center><input class='btn btn-default' type='submit' value='" . gT("PDF export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
$sOutput .= "\t<div class='printouttitle'><strong>" . gT("Survey name (ID):") . "</strong> {$sSurveyName} ({$iSurveyID})</div><p> \n";
LimeExpressionManager::StartProcessingPage(true);
// means that all variables are on the same page
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
LimeExpressionManager::StartProcessingGroup(1, $aSurveyInfo['anonymized'] != "N", $iSurveyID);
$printanswershonorsconditions = Yii::app()->getConfig('printanswershonorsconditions');
$aFullResponseTable = getFullResponseTable($iSurveyID, $sSRID, $sLanguage, $printanswershonorsconditions);
//Get the fieldmap @TODO: do we need to filter out some fields?
if ($aSurveyInfo['datestamp'] != "Y" || $sAnonymized == 'Y') {
unset($aFullResponseTable['submitdate']);
} else {
unset($aFullResponseTable['id']);
}
unset($aFullResponseTable['token']);
unset($aFullResponseTable['lastpage']);
unset($aFullResponseTable['startlanguage']);
unset($aFullResponseTable['datestamp']);
unset($aFullResponseTable['startdate']);
$sOutput .= "<table class='printouttable' >\n";
foreach ($aFullResponseTable as $sFieldname => $fname) {
if (substr($sFieldname, 0, 4) == 'gid_') {
$sOutput .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
$sOutput .= "\t<tr class='printanswersgroupdesc'><td colspan='2'>{$fname[1]}</td></tr>\n";
} elseif ($sFieldname == 'submitdate') {
if ($sAnonymized != 'Y') {
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]} {$sFieldname}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
}
} elseif (substr($sFieldname, 0, 4) != 'qid_') {
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>" . flattenText($fname[2]) . "</td></tr>";
}
}
$sOutput .= "</table>\n";
$sData['thissurvey'] = $aSurveyInfo;
$sOutput = templatereplace($sOutput, array(), $sData, '', $aSurveyInfo['anonymized'] == "Y", NULL, array(), true);
// Do a static replacement
ob_start(function ($buffer, $phase) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
//.........这里部分代码省略.........
示例7: send
public function send($filename)
{
$doc = new pdf($this->orientation);
if ($this->title) {
$doc->setHeaderData('', 0, $this->title);
$doc->setPrintHeader(true);
} else {
$doc->setPrintHeader(false);
}
$doc->setPrintFooter(false);
foreach ($this->pages as $page) {
$doc->AddPage();
if ($page->title) {
$doc->writeHtml('<h2>' . $page->title . '</h2>');
}
// Find extent of the table.
$rows = $this->get_row_count($page);
$cols = $this->get_col_count($page);
$relwidths = $this->compute_relative_widths($page);
$o = html_writer::start_tag('table', array('border' => 1, 'cellpadding' => 1));
for ($row = 0; $row < $rows; $row++) {
$o .= html_writer::start_tag('tr');
$col = 0;
while ($col < $cols) {
$span = 1;
if (isset($page->mergers[$row][$col])) {
$mergewidth = (int) $page->mergers[$row][$col];
if ($mergewidth >= 1) {
$span = $mergewidth;
}
}
$opts = array();
if ($row == 0 && $relwidths[$col] > 0) {
$opts['width'] = $relwidths[$col] . '%';
}
if ($span > 1) {
$opts['colspan'] = $span;
}
$o .= html_writer::start_tag('td', $opts);
$cell = '';
if (isset($page->cells[$row][$col])) {
$cell = s($page->cells[$row][$col]);
if (isset($page->formats[$row][$col])) {
$thisformat = $page->formats[$row][$col];
if ($thisformat == 'header') {
$cell = html_writer::tag('b', $cell);
} else {
if ($thisformat == 'boldit') {
$cell = html_writer::tag('i', $cell);
}
}
}
}
$o .= $cell;
$o .= html_writer::end_tag('td');
$col += $span;
}
$o .= html_writer::end_tag('tr');
}
$o .= html_Writer::end_tag('table');
$doc->writeHtml($o);
}
$doc->Output($filename . '.pdf');
}
示例8:
$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>.
Vestibulum sagittis venenatis urna, in pellentesque ipsum pulvinar eu. In nec <a href="http://www.google.com/">nulla libero</a>, eu sagittis diam. Aenean egestas pharetra urna, et tristique metus egestas nec. Aliquam erat volutpat. Fusce pretium dapibus tellus.', 0, 'L', 0, 1, '', '', true, null, true);
//Close and output PDF document
$pdf->Output('factura_' . $booking->id . '.pdf', 'D');
}
示例9: generate_combined_pdf_for_attempt
/**
* This function will take all of the compatible files for a submission
* and combine them into one PDF.
* @param int|\assign $assignment
* @param int $userid
* @param int $attemptnumber (-1 means latest attempt)
* @return stored_file
*/
public static function generate_combined_pdf_for_attempt($assignment, $userid, $attemptnumber)
{
global $CFG;
require_once $CFG->libdir . '/pdflib.php';
$assignment = self::get_assignment_from_param($assignment);
if (!$assignment->can_view_submission($userid)) {
\print_error('nopermission');
}
$files = self::list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber);
$pdf = new pdf();
if (!$files) {
// No valid submission files - create an empty pdf.
$pdf->AddPage();
} else {
// Create a mega joined PDF.
$compatiblepdfs = array();
foreach ($files as $file) {
$compatiblepdf = pdf::ensure_pdf_compatible($file);
if ($compatiblepdf) {
array_push($compatiblepdfs, $compatiblepdf);
}
}
$tmpdir = \make_temp_directory('assignfeedback_editpdf/combined/' . self::hash($assignment, $userid, $attemptnumber));
$tmpfile = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
@unlink($tmpfile);
$pagecount = $pdf->combine_pdfs($compatiblepdfs, $tmpfile);
if ($pagecount == 0) {
// We at least want a single blank page.
$pdf->AddPage();
@unlink($tmpfile);
$files = false;
}
}
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdf';
$record->filearea = self::COMBINED_PDF_FILEAREA;
$record->itemid = $grade->id;
$record->filepath = '/';
$record->filename = self::COMBINED_PDF_FILENAME;
$fs = \get_file_storage();
$fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid);
if (!$files) {
// This was a blank pdf.
$content = $pdf->Output(self::COMBINED_PDF_FILENAME, 'S');
$file = $fs->create_file_from_string($record, $content);
} else {
// This was a combined pdf.
$file = $fs->create_file_from_pathname($record, $tmpfile);
@unlink($tmpfile);
}
return $file;
}
示例10: array
function export_pdf($report, $fname = '') {
global $DB, $CFG;
require_once($CFG->libdir . '/pdflib.php');
$table = $report->table;
$matrix = array();
$fname == '' ? $filename = 'report' : $filename = $fname . '.pdf';
if (!empty($table->head)) {
$countcols = count($table->head);
$keys = array_keys($table->head);
$lastkey = end($keys);
foreach ($table->head as $key => $heading) {
$matrix[0][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($heading))));
}
}
if (!empty($table->data)) {
foreach ($table->data as $rkey => $row) {
foreach ($row as $key => $item) {
$matrix[$rkey + 1][$key] = str_replace("\n", ' ', htmlspecialchars_decode(strip_tags(nl2br($item))));
}
}
}
$table = "";
$table .="<table border=\"1\" cellpadding=\"5\"><thead><tr>";
$s = count($matrix);
reset($matrix);
$first_key = key($matrix);
for ($i = $first_key; $i < ($first_key + 1); $i++) {
foreach ($matrix[$i] as $col) {
$table .="<td><b>$col</b></td>";
}
}
$table .="</tr></thead><tbody>";
for ($i = ($first_key + 1); $i < count($matrix); $i++) {
$table .="<tr>";
foreach ($matrix[$i] as $col) {
$table .="<td>$col</td>";
}
$table .="</tr>";
}
$table .="</tbody></table>";
$table .="";
$doc = new pdf;
$doc->setPrintHeader(false);
$doc->setPrintFooter(false);
$doc->AddPage();
$doc->writeHTML($table);
if ($fname == '') {
$doc->Output();
exit;
} else {
$doc->Output($filename, 'F');
}
}
示例11: pdf
$this->TituloCabecera(30, $idioma['Materno']);
$this->TituloCabecera(40, $idioma['Nombres']);
$this->TituloCabecera(20, $idioma['Curso']);
$this->TituloCabecera(20, $idioma['Cuota']);
$this->TituloCabecera(25, $idioma['MontoPagar']);
}
}
$pdf = new pdf("P", "mm", "letter");
$pdf->AddPage();
$total = 0;
$i = 0;
foreach ($cuota->porPagar() as $cuo) {
$i++;
if ($i % 2 == 0) {
$nf = 1;
} else {
$nf = 0;
}
$total += $cuo['MontoPagar'];
$pdf->CuadroCuerpo(10, $i, $nf, "R");
$pdf->CuadroNombreSeparado(30, $cuo['Paterno'], 30, $cuo['Materno'], 40, $cuo['Nombres'], 1, $nf);
$pdf->CuadroCuerpo(20, $cuo['Curso'], $nf, "");
$pdf->CuadroCuerpo(20, $cuo['Cuota'], $nf, "C");
$pdf->CuadroCuerpo(25, number_format($cuo['MontoPagar'], 2), $nf, "R");
$pdf->Ln();
}
$pdf->Linea();
$pdf->CuadroCuerpo(150, $idioma['Total'], $nf, "R");
$pdf->CuadroCuerpo(25, number_format($total, 2), $nf, "R");
$pdf->Output($titulo, "I");
示例12: array
$langconfig = $CFG->dataroot . '/lang/' . $langdir . '/langconfig.php';
}
// Ignore parents here for now.
$string = array();
if (is_readable($langconfig)) {
include $langconfig;
if (is_array($string)) {
$languages[$langdir] = new stdClass();
$languages[$langdir]->langname = isset($string['thislanguage']) ? $string['thislanguage'] : '(unknown)';
$languages[$langdir]->alphabet = isset($string['alphabet']) ? '"' . $string['alphabet'] . '"' : '(no alphabet defined)';
}
}
}
$c .= '<dl>';
foreach ($languages as $langcode => $language) {
$c .= '<dt>' . $language->langname . ' (' . $langcode . ')</dt>';
$c .= '<dd>' . $language->alphabet . '</dd>';
}
$c .= '</dl>';
$doc->writeHTML($c);
$doc->Output('pdflibtestpage.pdf');
exit;
}
$PAGE->set_url('/lib/tests/other/pdflibtestpage.php');
$PAGE->set_context($context);
$PAGE->set_title('PDF library test');
$PAGE->set_heading('PDF library test');
echo $OUTPUT->header();
echo $OUTPUT->heading('Press the button to generate test PDF', 2);
echo $OUTPUT->continue_button(new moodle_url($PAGE->url, array('getpdf' => 1, 'fontfamily' => PDF_FONT_NAME_MAIN)));
echo $OUTPUT->footer();
示例13: datenbank
function ma2_pdf($id){
$return="";
$db=new datenbank();
$query="select * from rechnungen,mahnungen where rechnungen.renr=mahnungen.renr and mahnungen.manr='$id'";
$result=$db->query($query);
$rechnung=$db->get_object($result);
$result_kunde=$db->query("select * from kunden where kdnr=$rechnung->kunde");
$kunde=$db->get_object($result_kunde);
$pdf=new pdf('P', 'mm', 'A4');
$pdf->Open();
$pdf->AddPage();
$pdf->empfaenger($kunde->firma, $kunde->strasse." ".$kunde->hausnummer, $kunde->plz." ".$kunde->ort, $rechnung->manr, $rechnung->datum);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(80,5,"Mahnung");
$pdf->Ln(10);
$pdf->SetFont("Arial", "", 10);
$pdf->Write(5, "Sehr geehrte Damen und Herren,\nleider konnte ich noch keinen Zahlungseingang zur Rechnung $rechnung->renr feststellen. Hier die Auflistung der aufgrund dieser Rechnung unbezahlten Posten::\n\n");
$query="select posten.datum as Datum, posten.kommentar as Beschreibung, posten.anzahl as Anzahl, produkte.name as Artikel, produkte.preis as Preis, (produkte.preis*posten.anzahl) as Summe from posten, produkte where posten.rechnung='$rechnung->renr' and produkte.id=posten.produkt";
$result=$db->query($query);
$header=array("Datum", "Beschreibung", "Anzahl", "Artikel", "Preis", "Summe");
while($data[]=$db->get_row($result))
{
}
$gammel=array_pop($data);
$pdf->table($header, $data);
$pdf->Ln();
$result=$db->query("SELECT Sum( posten.anzahl * produkte.preis ) AS Gesamt, Sum( posten.anzahl * produkte.preis * mwst.satz / 100 ) AS MWST, mwst.satz FROM posten, produkte, mwst WHERE produkte.id = posten.produkt AND mwst.id = produkte.mwst AND posten.rechnung = '$rechnung->renr' AND produkte.id!='3' AND produkte.id!='4' GROUP BY mwst.satz");
$betrag=$db->get_object($result);
$result=$db->query("SELECT Sum( posten.anzahl * produkte.preis ) AS Gesamt, Sum( posten.anzahl * produkte.preis * mwst.satz / 100 ) AS MWST, mwst.satz FROM posten, produkte, mwst WHERE produkte.id = posten.produkt AND mwst.id = produkte.mwst AND posten.rechnung = '$rechnung->renr' AND produkte.id ='3' GROUP BY mwst.satz");
$betrag2=$db->get_object($result);
$result=$db->query("SELECT Sum( posten.anzahl * produkte.preis ) AS Gesamt, Sum( posten.anzahl * produkte.preis * mwst.satz / 100 ) AS MWST, mwst.satz FROM posten, produkte, mwst WHERE produkte.id = posten.produkt AND mwst.id = produkte.mwst AND posten.rechnung = '$rechnung->renr' AND produkte.id ='4' GROUP BY mwst.satz");
$betrag3=$db->get_object($result);
$pdf->Cell(100,5,"", 0, 0, 'L');
$pdf->Cell(35,5,"Gesamt:",0,0,'L');
$pdf->Cell(20,5,number_format(($betrag->Gesamt+$betrag2->Gesamt+$betrag3->Gesamt),2,",",".").EURO, 0, 1, 'R');
$pdf->Cell(100,5,"", 0, 0, 'L');
$pdf->Cell(35,5,"Mehrwertsteuer (".number_format($betrag->satz)."%):", 0, 0, 'L');
$pdf->Cell(20,5,number_format($betrag->MWST,2,",",".").EURO, 0, 1, 'R');
$pdf->Ln();
$pdf->Cell(100,5,"", 0, 0, 'L');
$pdf->Cell(35,5,"Mahnbetrag:", 0, 0, 'L');
$pdf->Cell(20,5,number_format($betrag2->Gesamt+$betrag->Gesamt+$betrag3->Gesamt+$betrag->MWST,2,",",".").EURO, 0, 1, 'R');
$pdf->Ln();
$pdf->Write(5, "Bitte überweisen Sie den oben genannten Betrag bis spätestens zum $rechnung->faellig auf das unten aufgeführte Konto.\nÜber eine weitere Zusammenarbeit mit Ihnen würde ich mich sehr freuen und verbleibe mit freundlichen Grüßen\n");
$pdf->Ln(15);
$pdf->Write(5, $GLOBALS["conf"]["rechnung"]["adresse"]["name"]);
$pdf->Image($GLOBALS["conf"]["rechnung"]["unterschrift"],25,$pdf->GetY()-10,50);
$this->output=0;
$pdf->Output();
return $return;
}
示例14: customcert_generate_grid_pdf
/**
* 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;
}
示例15: certificate_output_entity_completion
/**
* 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();
}