本文整理汇总了PHP中TCPDF::Annotation方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::Annotation方法的具体用法?PHP TCPDF::Annotation怎么用?PHP TCPDF::Annotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::Annotation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 041');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 041', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 16);
// add a page
$pdf->AddPage();
$txt = 'Example of File Attachment.
Double click on the icon to open the attached file.';
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// attach an external file
$pdf->Annotation(85, 27, 5, 5, 'text file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => 'tests/data/utf8test.txt'));
$this->comparePdfs($pdf);
}
示例2: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 036');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 036', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 16);
// add a page
$pdf->AddPage();
$txt = 'Example of Text Annotation.
Move your mouse over the yellow box or double click on it to display the annotation text.';
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// text annotation
$pdf->Annotation(83, 27, 10, 10, "Text annotation example\naccented letters test: à èéìòù", array('Subtype' => 'Text', 'Name' => 'Comment', 'T' => 'title example', 'Subj' => 'example', 'C' => array(255, 255, 0)));
$this->comparePdfs($pdf);
}
示例3: array
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 16);
// add a page
$pdf->AddPage();
// print a line using Cell()
$pdf->Cell(0, 12, 'Example 036', 1, 1, 'C');
// text annotation
$pdf->Annotation(124, 30, 10, 10, "Text annotation example\naccented letters test: àèéìòù", array('Subtype' => 'Text', 'Name' => 'Comment', 'T' => 'title example', 'Subj' => 'example', 'C' => array(255, 255, 0)));
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_036.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
示例4: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 015');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 015', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// Bookmark($txt, $level=0, $y=-1, $page='', $style='', $color=array(0,0,0))
// set font
$pdf->SetFont('times', 'B', 20);
// add a page
$pdf->AddPage();
// set a bookmark for the current position
$pdf->Bookmark('Chapter 1', 0, 0, '', 'B', array(0, 64, 128));
// print a line using Cell()
$pdf->Cell(0, 10, 'Chapter 1', 0, 1, 'L');
$pdf->SetFont('times', 'I', 14);
$pdf->Write(0, 'You can set PDF Bookmarks using the Bookmark() method.
You can set PDF Named Destinations using the setDestination() method.');
$pdf->SetFont('times', 'B', 20);
// add other pages and bookmarks
$pdf->AddPage();
$pdf->Bookmark('Paragraph 1.1', 1, 0, '', '', array(0, 0, 0));
$pdf->Cell(0, 10, 'Paragraph 1.1', 0, 1, 'L');
$pdf->AddPage();
$pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(0, 0, 0));
$pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L');
$pdf->AddPage();
$pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0, 0, 0));
$pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L');
$pdf->AddPage();
$pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(0, 0, 0));
$pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L');
$pdf->AddPage();
// add a named destination so you can open this document at this page using the link: "example_015.pdf#chapter2"
$pdf->setDestination('chapter2', 0, '');
// add a bookmark that points to a named destination
$pdf->Bookmark('Chapter 2', 0, 0, '', 'BI', array(128, 0, 0), -1, '#chapter2');
$pdf->Cell(0, 10, 'Chapter 2', 0, 1, 'L');
$pdf->SetFont('times', 'I', 14);
$pdf->Write(0, 'Once saved, you can open this document at this page using the link: "example_015.pdf#chapter2".');
$pdf->AddPage();
$pdf->setDestination('chapter3', 0, '');
$pdf->SetFont('times', 'B', 20);
$pdf->Bookmark('Chapter 3', 0, 0, '', 'B', array(0, 64, 128));
$pdf->Cell(0, 10, 'Chapter 3', 0, 1, 'L');
$pdf->AddPage();
$pdf->setDestination('chapter4', 0, '');
$pdf->SetFont('times', 'B', 20);
$pdf->Bookmark('Chapter 4', 0, 0, '', 'B', array(0, 64, 128));
$pdf->Cell(0, 10, 'Chapter 4', 0, 1, 'L');
$pdf->AddPage();
$pdf->Bookmark('Chapter 5', 0, 0, '', 'B', array(0, 128, 0));
$pdf->Cell(0, 10, 'Chapter 5', 0, 1, 'L');
$txt = 'Example of File Attachment.
Double click on the icon to open the attached file.';
$pdf->SetFont('helvetica', '', 10);
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// attach an external file TXT file
$pdf->Annotation(20, 50, 5, 5, 'TXT file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => 'tests/data/utf8test.txt'));
// attach an external file
$pdf->Annotation(50, 50, 5, 5, 'PDF file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => 'tests/_expected_pdfs/example_012.pdf'));
// add a bookmark that points to an embedded file
// NOTE: prefix the file name with the * character for generic file and with % character for PDF file
$pdf->Bookmark('TXT file', 0, 0, '', 'B', array(128, 0, 255), -1, '*utf8test.txt');
// add a bookmark that points to an embedded file
// NOTE: prefix the file name with the * character for generic file and with % character for PDF file
$pdf->Bookmark('PDF file', 0, 0, '', 'B', array(128, 0, 255), -1, '%tests/_expected_pdfs/example_012.pdf');
// add a bookmark that points to an external URL
$pdf->Bookmark('External URL', 0, 0, '', 'B', array(0, 0, 255), -1, 'http://www.tcpdf.org');
$this->comparePdfs($pdf);
}
示例5: dirname
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 16);
// add a page
$pdf->AddPage();
$txt = 'Example of File Attachment.
Double click on the icon to open the attached file.';
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// attach an external file
$pdf->Annotation(85, 27, 5, 5, 'text file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => 'data/utf8test.txt'));
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_041.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
示例6: array
$pdf->Bookmark('Chapter 3', 0, 0, '', 'B', array(0, 64, 128));
$pdf->Cell(0, 10, 'Chapter 3', 0, 1, 'L');
$pdf->AddPage();
$pdf->setDestination('chapter4', 0, '');
$pdf->SetFont('times', 'B', 20);
$pdf->Bookmark('Chapter 4', 0, 0, '', 'B', array(0, 64, 128));
$pdf->Cell(0, 10, 'Chapter 4', 0, 1, 'L');
$pdf->AddPage();
$pdf->Bookmark('Chapter 5', 0, 0, '', 'B', array(0, 128, 0));
$pdf->Cell(0, 10, 'Chapter 5', 0, 1, 'L');
$txt = 'Example of File Attachment.
Double click on the icon to open the attached file.';
$pdf->SetFont('helvetica', '', 10);
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// attach an external file TXT file
$pdf->Annotation(20, 50, 5, 5, 'TXT file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => '../cache/utf8test.txt'));
// attach an external file
$pdf->Annotation(50, 50, 5, 5, 'PDF file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => 'example_012.pdf'));
// add a bookmark that points to an embedded file
// NOTE: prefix the file name with the * character for generic file and with % character for PDF file
$pdf->Bookmark('TXT file', 0, 0, '', 'B', array(128, 0, 255), -1, '*utf8test.txt');
// add a bookmark that points to an embedded file
// NOTE: prefix the file name with the * character for generic file and with % character for PDF file
$pdf->Bookmark('PDF file', 0, 0, '', 'B', array(128, 0, 255), -1, '%example_012.pdf');
// add a bookmark that points to an external URL
$pdf->Bookmark('External URL', 0, 0, '', 'B', array(0, 0, 255), -1, 'http://www.tcpdf.org');
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_015.pdf', 'I');
//============================================================+
// END OF FILE
示例7: emarking_create_response_pdf
/**
* Creates the PDF version (downloadable) of the whole feedback produced by the teacher/tutor
*
* @param unknown $draft
* @param unknown $student
* @param unknown $context
* @param unknown $cmid
* @return boolean
*/
function emarking_create_response_pdf($draft, $student, $context, $cmid)
{
global $CFG, $DB;
require_once $CFG->libdir . '/pdflib.php';
$fs = get_file_storage();
if (!($submission = $DB->get_record('emarking_submission', array('id' => $draft->submissionid)))) {
return false;
}
if (!($pages = $DB->get_records('emarking_page', array('submission' => $submission->id, 'student' => $student->id), 'page ASC'))) {
return false;
}
if (!($emarking = $DB->get_record('emarking', array('id' => $submission->emarking)))) {
return false;
}
$numpages = count($pages);
$sqlcomments = "SELECT ec.id,\n\t\t\tec.posx,\n\t\t\tec.posy,\n\t\t\tec.rawtext,\n\t\t\tec.pageno,\n\t\t\tgrm.maxscore,\n\t\t\tec.levelid,\n\t\t\tec.width,\n\t\t\tec.colour,\n\t\t\tec.textformat,\n\t\t\tgrl.score AS score,\n\t\t\tgrl.definition AS leveldesc,\n\t\t\tgrc.id AS criterionid,\n\t\t\tgrc.description AS criteriondesc,\n\t\t\tu.id AS markerid, CONCAT(u.firstname,' ',u.lastname) AS markername\n\t\t\tFROM {emarking_comment} AS ec\n\t\t\tINNER JOIN {emarking_page} AS ep ON (ec.draft = :draft AND ec.page = ep.id)\n\t\t\tLEFT JOIN {user} AS u ON (ec.markerid = u.id)\n\t\t\tLEFT JOIN {gradingform_rubric_levels} AS grl ON (ec.levelid = grl.id)\n\t\t\tLEFT JOIN {gradingform_rubric_criteria} AS grc ON (grl.criterionid = grc.id)\n\t\t\tLEFT JOIN (\n\t\t\tSELECT grl.criterionid, max(score) AS maxscore\n\t\t\tFROM {gradingform_rubric_levels} AS grl\n\t\t\tGROUP BY grl.criterionid\n\t\t\t) AS grm ON (grc.id = grm.criterionid)\n\t\t\tWHERE ec.pageno > 0\n\t\t\tORDER BY ec.pageno";
$params = array('draft' => $draft->id);
$comments = $DB->get_records_sql($sqlcomments, $params);
$commentsperpage = array();
foreach ($comments as $comment) {
if (!isset($commentsperpage[$comment->pageno])) {
$commentsperpage[$comment->pageno] = array();
}
$commentsperpage[$comment->pageno][] = $comment;
}
// Parameters for PDF generation
$iconsize = 5;
$tempdir = emarking_get_temp_dir_path($emarking->id);
if (!file_exists($tempdir)) {
mkdir($tempdir);
}
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($student->firstname . ' ' . $student->lastname);
$pdf->SetTitle($emarking->name);
$pdf->SetSubject('Exam feedback');
$pdf->SetKeywords('feedback, emarking');
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 036', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 16);
foreach ($pages as $page) {
// add a page
$pdf->AddPage();
// get the current page break margin
$bMargin = $pdf->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $pdf->getAutoPageBreak();
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// set bacground image
$pngfile = $fs->get_file_by_id($page->file);
$img_file = emarking_get_path_from_hash($tempdir, $pngfile->get_pathnamehash());
$pdf->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
// restore auto-page-break status
// $pdf->SetAutoPageBreak($auto_page_break, $bMargin);
// set the starting point for the page content
$pdf->setPageMark();
$dimensions = $pdf->getPageDimensions();
if (isset($commentsperpage[$page->page])) {
foreach ($commentsperpage[$page->page] as $comment) {
$content = $comment->rawtext;
$posx = (int) ((double) $comment->posx * $dimensions['w']);
$posy = (int) ((double) $comment->posy * $dimensions['h']);
if ($comment->textformat == 1) {
// text annotation
$pdf->Annotation($posx, $posy, 6, 6, $content, array('Subtype' => 'Text', 'StateModel' => 'Review', 'State' => 'None', 'Name' => 'Comment', 'NM' => 'Comment' . $comment->id, 'T' => $comment->markername, 'Subj' => 'example', 'C' => array(0, 0, 255)));
} elseif ($comment->textformat == 2) {
//.........这里部分代码省略.........
示例8: emarking_create_response_pdf
/**
* Creates the PDF version (downloadable) of the whole feedback produced by the teacher/tutor
*
* @param unknown $draft
* @param unknown $student
* @param unknown $context
* @param unknown $cmid
* @return boolean
*/
function emarking_create_response_pdf($draft, $student, $context, $cmid)
{
global $CFG, $DB;
require_once $CFG->libdir . '/pdflib.php';
$fs = get_file_storage();
if (!($submission = $DB->get_record('emarking_submission', array('id' => $draft->submissionid)))) {
return false;
}
if (!($pages = $DB->get_records('emarking_page', array('submission' => $submission->id), 'page ASC'))) {
return false;
}
if (!($emarking = $DB->get_record('emarking', array('id' => $submission->emarking)))) {
return false;
}
$numpages = count($pages);
$sqlcomments = "SELECT ec.id,\n\t\t\tec.posx,\n\t\t\tec.posy,\n\t\t\tec.rawtext,\n\t\t\tec.pageno,\n\t\t\tgrm.maxscore,\n\t\t\tec.levelid,\n\t\t\tec.width,\n\t\t\tec.colour,\n\t\t\tec.textformat,\n\t\t\tgrl.score AS score,\n\t\t\tgrl.definition AS leveldesc,\n\t\t\tgrc.id AS criterionid,\n\t\t\tgrc.description AS criteriondesc,\n\t\t\tu.id AS markerid, CONCAT(u.firstname,' ',u.lastname) AS markername\n\t\t\tFROM {emarking_comment} ec\n\t\t\tINNER JOIN {emarking_page} ep ON (ec.draft = :draft AND ec.page = ep.id)\n\t\t\tLEFT JOIN {user} u ON (ec.markerid = u.id)\n\t\t\tLEFT JOIN {gradingform_rubric_levels} grl ON (ec.levelid = grl.id)\n\t\t\tLEFT JOIN {gradingform_rubric_criteria} grc ON (grl.criterionid = grc.id)\n\t\t\tLEFT JOIN (\n\t\t\tSELECT grl.criterionid, max(score) AS maxscore\n\t\t\tFROM {gradingform_rubric_levels} grl\n\t\t\tGROUP BY grl.criterionid\n\t\t\t) AS grm ON (grc.id = grm.criterionid)\n\t\t\tWHERE ec.pageno > 0\n\t\t\tORDER BY ec.pageno";
$params = array('draft' => $draft->id);
$comments = $DB->get_records_sql($sqlcomments, $params);
$commentsperpage = array();
foreach ($comments as $comment) {
if (!isset($commentsperpage[$comment->pageno])) {
$commentsperpage[$comment->pageno] = array();
}
$commentsperpage[$comment->pageno][] = $comment;
}
// Parameters for PDF generation.
$iconsize = 5;
$tempdir = emarking_get_temp_dir_path($emarking->id);
if (!file_exists($tempdir)) {
emarking_initialize_directory($tempdir, true);
}
// Create new PDF document.
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// Set document information.
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($student->firstname . ' ' . $student->lastname);
$pdf->SetTitle($emarking->name);
$pdf->SetSubject('Exam feedback');
$pdf->SetKeywords('feedback, emarking');
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// Set default header data.
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 036', PDF_HEADER_STRING);
// Set header and footer fonts.
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// Set default monospaced font.
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// Set margins.
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// Set auto page breaks.
$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
// Set image scale factor.
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// Set some language-dependent strings (optional).
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// Set font.
$pdf->SetFont('times', '', 16);
foreach ($pages as $page) {
// Add a page.
$pdf->AddPage();
// Get the current page break margin.
$bmargin = $pdf->getBreakMargin();
// Get current auto-page-break mode.
$autopagebreak = $pdf->getAutoPageBreak();
// Disable auto-page-break.
$pdf->SetAutoPageBreak(false, 0);
// Set bacground image.
$pngfile = $fs->get_file_by_id($page->file);
$imgfile = emarking_get_path_from_hash($tempdir, $pngfile->get_pathnamehash());
$pdf->Image($imgfile, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
// Restore auto-page-break status.
// Set the starting point for the page content.
$pdf->setPageMark();
$dimensions = $pdf->getPageDimensions();
if (isset($commentsperpage[$page->page])) {
foreach ($commentsperpage[$page->page] as $comment) {
$content = $comment->rawtext;
$posx = (int) ((double) $comment->posx * 210);
$posy = (int) ((double) $comment->posy * 297);
if ($comment->textformat == 1) {
// Text annotation.
$pdf->Annotation($posx, $posy, 6, 6, $content, array('Subtype' => 'Text', 'StateModel' => 'Review', 'State' => 'None', 'Name' => 'Comment', 'NM' => 'Comment' . $comment->id, 'T' => $comment->markername, 'Subj' => 'example', 'C' => array(0, 0, 255)));
$pdf->Bookmark(get_string('comment', 'mod_emarking') . ' ' . $comment->id, 0, $posy);
} else {
if ($comment->textformat == 2) {
//.........这里部分代码省略.........
示例9: array
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
//initialize document
$pdf->AliasNbPages();
// add a page
$pdf->AddPage();
// ---------------------------------------------------------
// set font
$pdf->SetFont('times', '', 16);
// print a line using Cell()
$pdf->Cell(0, 12, 'File Attachment', 1, 1, 'C');
// attach an external file
$pdf->Annotation(124, 28, 4, 4, 'text file', array('Subtype' => 'FileAttachment', 'Name' => 'PushPin', 'FS' => '../cache/utf8test.txt'));
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output("example_041.pdf", "I");
//============================================================+
// END OF FILE
//============================================================+