Added option to remove header/footer/watermark from PDF when printing certificates - closes #3708

skala
Yannick Warnier 12 years ago
parent 6f3c2a6d3c
commit 90b94c9ebd
  1. 4
      main/gradebook/gradebook_display_certificate.php
  2. 24
      main/inc/lib/pdf.lib.php

@ -59,7 +59,9 @@ switch ($action) {
}
}
if (!empty($certificate_path_list)) {
$pdf->html_to_pdf($certificate_path_list, get_lang('Certificates'));
// Print certificates (without the common header/footer/watermark
// stuff) and return as one multiple-pages PDF
$pdf->html_to_pdf($certificate_path_list, get_lang('Certificates'), null, false, false);
}
break;
case 'generate_all_certificates':

@ -44,7 +44,11 @@ class PDF {
$this->pdf = new mPDF('UTF-8', $page_format, '', '', $params['left'], $params['right'], $params['top'], $params['bottom'], 8, 8, $orientation);
}
/**
* Export the given HTML to PDF, using a global template
* @param string the HTML content
* @uses export/table_pdf.tpl
*/
function html_to_pdf_with_template($content) {
Display :: display_no_header();
@ -96,10 +100,12 @@ class PDF {
* @param mixed could be an html file path or an array with paths example: /var/www/myfile.html or array('/myfile.html','myotherfile.html') or even an indexed array with both 'title' and 'path' indexes for each element like array(0=>array('title'=>'Hello','path'=>'file.html'),1=>array('title'=>'Bye','path'=>'file2.html'));
* @param string pdf name
* @param string course code (if you are using html that are located in the document tool you must provide this)
* @param bool Whether to print the header, footer and watermark (true) or just the content (false)
* @return void
*/
public function html_to_pdf($html_file_array, $pdf_name = '', $course_code = null, $print_title = false) {
public function html_to_pdf($html_file_array, $pdf_name = '', $course_code = null, $print_title = false, $complete_style = true) {
if($complete_style === false) { error_log(__FUNCTION__.' with no style'); }
if (empty($html_file_array)) {
return false;
}
@ -130,7 +136,7 @@ class PDF {
);
//Formatting the pdf
self::format_pdf($course_data);
self::format_pdf($course_data, $complete_style);
$counter = 1;
@ -533,7 +539,14 @@ class PDF {
$this->custom_footer = $footer;
}
public function format_pdf($course_data) {
/**
* Pre-formats a PDF to the right size and, if not stated otherwise, with
* header, footer and watermark (if any)
* @param array General course information (to fill headers)
* @param bool Whether we want headers, footers and watermark or not
*/
public function format_pdf($course_data, $complete = true) {
if($complete === false) {error_log('Asked with no decoration');}
$course_code = null;
if (!empty( $course_data)) {
$course_code = $course_data['code'];
@ -548,6 +561,8 @@ class PDF {
$this->pdf->useOnlyCoreFonts = true;
$this->pdf->mirrorMargins = 1; // Use different Odd/Even headers and footers and mirror margins
// Add decoration only if not stated otherwise
if ($complete) {
//Adding watermark
if (api_get_setting('pdf_export_watermark_enable') == 'true') {
$watermark_file = self::get_watermark($course_code);
@ -590,4 +605,5 @@ class PDF {
$this->pdf->SetHTMLFooter($this->custom_footer);
}
}
}
}

Loading…
Cancel
Save