当前位置: 首页>>代码示例>>PHP>>正文


PHP pdf::AddPage方法代码示例

本文整理汇总了PHP中pdf::AddPage方法的典型用法代码示例。如果您正苦于以下问题:PHP pdf::AddPage方法的具体用法?PHP pdf::AddPage怎么用?PHP pdf::AddPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pdf的用法示例。


在下文中一共展示了pdf::AddPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:kmahesh541,项目名称:mitclone,代码行数:17,代码来源:export_reports.php

示例2: 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();
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:57,代码来源:certificate.php

示例3: 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");
     }
     $clang = SetSurveyLanguage($iSurveyID, $sLanguage);
     $aSurveyInfo = getSurveyInfo($iSurveyID, $sLanguage);
     //SET THE TEMPLATE DIRECTORY
     if (!isset($aSurveyInfo['templatedir']) || !$aSurveyInfo['templatedir']) {
         $aSurveyInfo['templatedir'] = Yii::app()->getConfig('defaulttemplate');
     }
     $sTemplate = validateTemplateDir($aSurveyInfo['templatedir']);
     //Survey is not finished or don't exist
     if (!isset($_SESSION['survey_' . $iSurveyID]['finished']) || !isset($_SESSION['survey_' . $iSurveyID]['srid'])) {
         sendCacheHeaders();
         doHeader();
         echo templatereplace(file_get_contents(getTemplatePath($sTemplate) . '/startpage.pstpl'), array());
         echo "<center><br />\n" . "\t<font color='RED'><strong>" . $clang->gT("Error") . "</strong></font><br />\n" . "\t" . $clang->gT("We are sorry but your session has expired.") . "<br />" . $clang->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($clang->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(getTemplatePath($sTemplate) . '/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");}
     if ($aSurveyInfo['printanswers'] == 'N') {
         die;
         //Die quietly if print answers is not permitted
     }
     //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
     $sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post') . "<center><input type='submit' value='" . $clang->gT("PDF export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
     if ($sExportType == 'pdf') {
         //require (Yii::app()->getConfig('rootdir').'/application/config/tcpdf.php');
         Yii::import('application.libraries.admin.pdf', true);
         Yii::import('application.helpers.pdfHelper');
         $aPdfLanguageSettings = pdfHelper::getPdfLanguageSettings($clang->langcode);
         $oPDF = new pdf();
         $oPDF->SetTitle($clang->gT("Survey name (ID)", 'unescaped') . ": {$sSurveyName} ({$iSurveyID})");
         $oPDF->SetSubject($sSurveyName);
         $oPDF->SetDisplayMode('fullpage', 'two');
         $oPDF->setLanguageArray($aPdfLanguageSettings['lg']);
         $oPDF->setHeaderFont(array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_MAIN));
         $oPDF->setFooterFont(array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_DATA));
         $oPDF->SetFont($aPdfLanguageSettings['pdffont'], '', $aPdfLanguageSettings['pdffontsize']);
         $oPDF->AddPage();
         $oPDF->titleintopdf($clang->gT("Survey name (ID)", 'unescaped') . ": {$sSurveyName} ({$iSurveyID})");
     }
     $sOutput .= "\t<div class='printouttitle'><strong>" . $clang->gT("Survey name (ID):") . "</strong> {$sSurveyName} ({$iSurveyID})</div><p>&nbsp;\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";
         } elseif (substr($sFieldname, 0, 4) == 'qid_') {
//.........这里部分代码省略.........
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:101,代码来源:PrintanswersController.php

示例4: 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;
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:62,代码来源:document_services.php

示例5: pdf

					$j=$i;
					$l=0;
					$nl++;
				}
				else
					$i++;
			}
			return $nl;
		}
	}
	
	$pdf = new pdf('L','mm','A4');
	$pdf->AliasNbPages();
	$titulos = array('FECHA','F. RECEPCION','SUCURSAL','GUIA','ORIGEN','DESTINO','INCIDENTE','RECIBIO','UNIDAD','RUTA');
	$medidas = array(15,20,15,22,12,12,30,80,20,55);
	$pdf->AddPage();
	
	$pdf->SetFont('Arial','B',7);
	//Table with 20 rows and 4 columns
	
	$pdf->SetWidths($medidas);
	
	$pdf->Titulos($titulos,$medidas);
	
	$pdf->SetFont('Arial','',7);
	for($i=0;$i<count($data);$i++){
		$pdf->Row($data[$i]);
	}
	
	$pdf->Output();
?>
开发者ID:sigmadesarrollo,项目名称:logisoft,代码行数:31,代码来源:danosFaltantes.php

示例6: generate_statistics


//.........这里部分代码省略.........
         if (incompleteAnsFilterState() == "complete" || incompleteAnsFilterState() == "incomplete") {
             $query .= " AND ";
         } else {
             $query .= " WHERE ";
         }
         //add filter criteria to SQL
         $query .= implode(" AND ", $selects);
     }
     //get me some data Scotty
     $results = Yii::app()->db->createCommand($query)->queryScalar();
     if ($total) {
         $percent = sprintf("%01.2f", $results / $total * 100);
     }
     switch ($outputType) {
         case "xls":
             $this->xlsRow = 0;
             $this->sheet->write($this->xlsRow, 0, gT("Number of records in this query:", 'unescaped'));
             $this->sheet->writeNumber($this->xlsRow, 1, $results);
             $this->xlsRow++;
             $this->sheet->write($this->xlsRow, 0, gT("Total records in survey:", 'unescaped'));
             $this->sheet->writeNumber($this->xlsRow, 1, $total);
             if ($total) {
                 $this->xlsRow++;
                 $this->sheet->write($this->xlsRow, 0, gT("Percentage of total:", 'unescaped'));
                 $this->sheet->writeNumber($this->xlsRow, 1, $results / $total, $this->xlsPercents);
             }
             break;
         case 'pdf':
             // add summary to pdf
             $array = array(array(gT("Number of records in this query:", 'unescaped'), $results), array(gT("Total records in survey:", 'unescaped'), $total));
             if ($total) {
                 $array[] = array(gT("Percentage of total:", 'unescaped'), $percent . "%");
             }
             $this->pdf->AddPage('P', ' A4');
             $this->pdf->Bookmark(gT("Results", 'unescaped'), 0, 0);
             $this->pdf->titleintopdf(gT("Results", 'unescaped'), gT("Survey", 'unescaped') . " " . $surveyid);
             $this->pdf->tableintopdf($array);
             break;
         case 'html':
             $sOutputHTML .= "<br />\n<table class='statisticssummary' >\n" . "\t<thead><tr><th colspan='2'>" . gT("Results") . "</th></tr></thead>\n" . "\t<tr><th >" . gT("Number of records in this query:") . '</th>' . "<td>{$results}</td></tr>\n" . "\t<tr><th>" . gT("Total records in survey:") . '</th>' . "<td>{$total}</td></tr>\n";
             //only calculate percentage if $total is set
             if ($total) {
                 $percent = sprintf("%01.2f", $results / $total * 100);
                 $sOutputHTML .= "\t<tr><th align='right'>" . gT("Percentage of total:") . '</th>' . "<td>{$percent}%</td></tr>\n";
             }
             $sOutputHTML .= "</table>\n";
             break;
         default:
             break;
     }
     //put everything from $selects array into a string connected by AND
     //This string ($sql) can then be passed on to other functions so you can
     //browse these results
     if (isset($selects) && $selects) {
         $sql = implode(" AND ", $selects);
     } elseif (!empty($newsql)) {
         $sql = $newsql;
     }
     if (!isset($sql) || !$sql) {
         $sql = null;
     }
     //only continue if we have something to output
     if ($results > 0) {
         if ($outputType == 'html' && $browse === true && Permission::model()->hasSurveyPermission($surveyid, 'responses', 'read')) {
             //add a buttons to browse results
             $sOutputHTML .= CHtml::form(array("admin/responses/sa/browse/surveyid/{$surveyid}"), 'post', array('target' => '_blank')) . "\n" . "\t\t<p>" . "\t\t\t<input type='submit' value='" . gT("Browse") . "'  />\n" . "\t\t\t<input type='hidden' name='sid' value='{$surveyid}' />\n" . "\t\t\t<input type='hidden' name='sql' value=\"{$sql}\" />\n" . "\t\t\t<input type='hidden' name='subaction' value='all' />\n" . "\t\t</p>" . "\t\t</form>\n";
开发者ID:krsandesh,项目名称:LimeSurvey,代码行数:67,代码来源:statistics_helper.php

示例7: 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)
 {
     global $siteadminname, $siteadminemail;
     Yii::app()->loadHelper("frontend");
     Yii::import('application.libraries.admin.pdf');
     $surveyid = (int) $surveyid;
     Yii::app()->loadHelper('database');
     if (isset($_SESSION['survey_' . $surveyid]['sid'])) {
         $surveyid = $_SESSION['survey_' . $surveyid]['sid'];
     } else {
         die('Invalid survey/session');
     }
     //Debut session time out
     if (!isset($_SESSION['survey_' . $surveyid]['finished']) || !isset($_SESSION['survey_' . $surveyid]['srid'])) {
         //require_once($rootdir.'/classes/core/language.php');
         $baselang = Survey::model()->findByPk($surveyid)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($baselang);
         //A nice exit
         sendCacheHeaders();
         doHeader();
         echo templatereplace(file_get_contents(getTemplatePath(validateTemplateDir("default")) . "/startpage.pstpl"), array(), array());
         echo "<center><br />\n" . "\t<font color='RED'><strong>" . $clang->gT("Error") . "</strong></font><br />\n" . "\t" . $clang->gT("We are sorry but your session has expired.") . "<br />" . $clang->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($clang->gT("Please contact %s ( %s ) for further assistance."), $siteadminname, $siteadminemail) . "\n" . "</center><br />\n";
         echo templatereplace(file_get_contents(getTemplatePath(validateTemplateDir("default")) . "/endpage.pstpl"), array(), array());
         doFooter();
         exit;
     }
     //Fin session time out
     $id = $_SESSION['survey_' . $surveyid]['srid'];
     //I want to see the answers with this id
     $clang = $_SESSION['survey_' . $surveyid]['s_lang'];
     //Ensure script is not run directly, avoid path disclosure
     //if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die( "browse - Cannot run this script directly");}
     // Set the language for dispay
     //require_once($rootdir.'/classes/core/language.php');  // has been secured
     if (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
         $clang = SetSurveyLanguage($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
         $language = $_SESSION['survey_' . $surveyid]['s_lang'];
     } else {
         $language = Survey::model()->findByPk($surveyid)->language;
         $clang = SetSurveyLanguage($surveyid, $language);
     }
     // Get the survey inforamtion
     $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>&nbsp;\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_') {
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:PrintanswersController.php

示例8: 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;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:81,代码来源:document_services.php

示例9: 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');
 }
开发者ID:ninelanterns,项目名称:moodle-mod_scheduler,代码行数:64,代码来源:exportlib.php

示例10: elang_pluginfile

/**
 * Serves the files from the elang file areas
 *
 * @param   stdClass  $course         the course object
 * @param   stdClass  $cm             the course module object
 * @param   stdClass  $context        the elang's context
 * @param   string    $filearea       the name of the file area
 * @param   array     $args           extra arguments (itemid, path)
 * @param   boolean   $forcedownload  whether or not force download
 * @param   array     $options        additional options affecting the file serving
 *
 * @return  void
 *
 * @category  files
 *
 * @since   0.0.1
 */
function elang_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options = array())
{
    global $DB, $CFG, $USER;
    require_once dirname(__FILE__) . '/locallib.php';
    if ($context->contextlevel != CONTEXT_MODULE) {
        send_file_not_found();
    }
    require_login($course, true, $cm);
    if (!has_capability('mod/elang:view', $context)) {
        send_file_not_found();
    }
    if ($filearea == 'subtitle') {
        $vtt = new \Captioning\Format\WebvttFile();
        $idlang = $cm->instance;
        $records = $DB->get_records('elang_cues', array('id_elang' => $idlang), 'begin ASC');
        $elang = $DB->get_record('elang', array('id' => $idlang));
        $options = json_decode($elang->options, true);
        $repeatedunderscore = isset($options['repeatedunderscore']) ? $options['repeatedunderscore'] : 10;
        $i = 0;
        $users = $DB->get_records('elang_users', array('id_elang' => $idlang, 'id_user' => $USER->id), '', 'id_cue,json');
        foreach ($records as $id => $record) {
            if (isset($users[$id])) {
                $data = json_decode($users[$id]->json, true);
            } else {
                $data = array();
            }
            $cue = new \Captioning\Format\WebvttCue(\Captioning\Format\WebvttCue::ms2tc($record->begin), \Captioning\Format\WebvttCue::ms2tc($record->end), Elang\generateCueText(json_decode($record->json, true), $data, '-', $repeatedunderscore));
            $i++;
            $cue->setIdentifier($i);
            $vtt->addCue($cue);
        }
        send_file($vtt->build()->getFileContent(), end($args), 0, 0, true, false, 'text/vtt');
    } elseif ($filearea == 'pdf') {
        $idlang = $cm->instance;
        $records = $DB->get_records('elang_cues', array('id_elang' => $idlang), 'begin ASC');
        $elang = $DB->get_record('elang', array('id' => $idlang));
        $options = json_decode($elang->options, true);
        $repeatedunderscore = isset($options['repeatedunderscore']) ? $options['repeatedunderscore'] : 10;
        require_once $CFG->libdir . '/pdflib.php';
        $doc = new pdf();
        $doc->SetMargins(isset($options['left']) ? $options['left'] : 20, isset($options['top']) ? $options['top'] : 20);
        $doc->SetFont('', '', isset($options['size']) ? $options['size'] : 16);
        $doc->setPrintHeader(false);
        $doc->setPrintFooter(false);
        $doc->AddPage();
        $doc->WriteHtml('<h1>' . sprintf(get_string('pdftitle', 'elang'), $course->fullname) . '</h1>');
        $doc->WriteHtml('<h2>' . sprintf(get_string('pdfsubtitle', 'elang'), Elang\generateTitle($elang, $options), userdate($elang->timecreated, get_string('strftimedaydate'))) . '</h2>');
        $doc->WriteHtml($elang->intro);
        $i = 1;
        foreach ($records as $id => $record) {
            $doc->Write(5, '', '', false, '', true);
            $doc->WriteHtml('<h3>' . sprintf(get_string('pdfcue', 'elang'), $i++, \Captioning\Format\WebvttCue::ms2tc($record->begin), \Captioning\Format\WebvttCue::ms2tc($record->end)) . '</h3>');
            $doc->Write(5, Elang\generateCueText(json_decode($record->json, true), array(), '_', $repeatedunderscore), '', false, '', true);
        }
        send_file($doc->Output('', 'S'), end($args), 0, 0, true, false, 'application/pdf');
    } else {
        $fs = get_file_storage();
        $relativepath = implode('/', $args);
        $fullpath = rtrim('/' . $context->id . '/mod_elang/' . $filearea . '/0/' . $relativepath, '/');
        $file = $fs->get_file_by_hash(sha1($fullpath));
        if (!$file) {
            send_file_not_found();
        }
        send_stored_file($file, 86400, 0, $forcedownload, $options);
    }
}
开发者ID:e-lang,项目名称:moodle-mod_elang,代码行数:83,代码来源:lib.php

示例11: printToPdf

 function printToPdf($htmlContent)
 {
     $pdf = new pdf();
     $pdf->print_header = false;
     $pdf->print_footer = false;
     $pdf->AddPage();
     $pdf->writeHTML($htmlcontent, true, 0, true, 0);
     $pdf->output('document.pdf', 'I');
 }
开发者ID:laiello,项目名称:poodll.poodll23,代码行数:9,代码来源:assignment.class.php

示例12: 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');
        }
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:59,代码来源:lib.php

示例13: pdf

if ($getpdf) {
    $doc = new pdf();
    $doc->SetTitle('Moodle PDF library test');
    $doc->SetAuthor('Moodle ' . $CFG->release);
    $doc->SetCreator('lib/tests/other/pdflibtestpage.php');
    $doc->SetKeywords('Moodle, PDF');
    $doc->SetSubject('This has been generated by Moodle as its PDF library test page');
    $doc->SetMargins(15, 30);
    $doc->setPrintHeader(true);
    $doc->setHeaderMargin(10);
    $doc->setHeaderFont(array($fontfamily, 'b', 10));
    $doc->setHeaderData('pix/moodlelogo-med-white.gif', 40, $SITE->fullname, $CFG->wwwroot);
    $doc->setPrintFooter(true);
    $doc->setFooterMargin(10);
    $doc->setFooterFont(array($fontfamily, '', 8));
    $doc->AddPage();
    $doc->SetTextColor(255, 255, 255);
    $doc->SetFillColor(255, 203, 68);
    $doc->SetFont($fontfamily, 'B', 24);
    $doc->Cell(0, 0, 'Moodle PDF library test', 0, 1, 'C', 1);
    $doc->SetFont($fontfamily, '', 12);
    $doc->Ln(6);
    $doc->SetTextColor(0, 0, 0);
    $c = '<h3>General information</h3>';
    $c .= 'Moodle release: ' . $CFG->release . '<br />';
    $c .= 'PDF producer: TCPDF ' . TCPDF_STATIC::getTCPDFVersion() . ' (http://www.tcpdf.org) <br />';
    $c .= 'Font family used: ' . $fontfamily . '<br />';
    $c .= '<h3>Current settings</h3>';
    $c .= '<table border="1"  cellspacing="0" cellpadding="1">';
    foreach (array('K_PATH_MAIN', 'K_PATH_URL', 'K_PATH_FONTS', 'PDF_FONT_NAME_MAIN', 'K_PATH_CACHE', 'K_PATH_IMAGES', 'K_BLANK_IMAGE', 'K_CELL_HEIGHT_RATIO', 'K_SMALL_RATIO', 'PDF_CUSTOM_FONT_PATH', 'PDF_DEFAULT_FONT') as $setting) {
        if (defined($setting)) {
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:pdflibtestpage.php

示例14: 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;
	}
开发者ID:BackupTheBerlios,项目名称:webfaktura,代码行数:51,代码来源:class.kunden.inc.php

示例15: customcert_generate_pdf

/**
 * Generate the PDF for the specified customcert and user.
 *
 * @param stdClass $customcert
 * @param bool $preview true if it is a preview, false otherwise
 */
function customcert_generate_pdf($customcert, $preview = false)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/pdflib.php';
    // Get the pages for the customcert, there should always be at least one page for each customcert.
    if ($pages = $DB->get_records('customcert_pages', array('customcertid' => $customcert->id), 'pagenumber ASC')) {
        // Create the pdf object.
        $pdf = new pdf();
        if (!empty($customcert->protection)) {
            $protection = explode(', ', $customcert->protection);
            $pdf->SetProtection($protection);
        }
        $pdf->setPrintHeader(false);
        $pdf->setPrintFooter(false);
        $pdf->SetTitle($customcert->name);
        $pdf->SetAutoPageBreak(true, 0);
        // Remove full-stop at the end, if it exists, to avoid "..pdf" being created and being filtered by clean_filename.
        $filename = rtrim($customcert->name, '.');
        $filename = clean_filename($filename . '.pdf');
        // Loop through the pages and display their content.
        foreach ($pages as $page) {
            // Add the page to the PDF.
            if ($page->width > $page->height) {
                $orientation = 'L';
            } else {
                $orientation = 'P';
            }
            $pdf->AddPage($orientation, array($page->width, $page->height));
            $pdf->SetMargins(0, 0, $page->margin);
            // Get the elements for the page.
            if ($elements = $DB->get_records('customcert_elements', array('pageid' => $page->id), 'sequence ASC')) {
                // Loop through and display.
                foreach ($elements as $element) {
                    // Get an instance of the element class.
                    if ($e = customcert_get_element_instance($element)) {
                        $e->render($pdf, $preview);
                    }
                }
            }
        }
        $pdf->Output($filename, 'D');
    }
}
开发者ID:rezaies,项目名称:moodle-mod_customcert,代码行数:49,代码来源:locallib.php


注:本文中的pdf::AddPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。