Internal: Disable pagination in certificate PDF generation - refs BT#21812

pull/5616/head
christianbeeznst 1 year ago
parent 53480232da
commit fb657d0105
  1. 1
      public/main/inc/lib/certificate.lib.php
  2. 23
      public/main/inc/lib/pdf.lib.php

@ -748,6 +748,7 @@ class Certificate extends Model
false, false,
true, true,
true, true,
true,
true true
); );
} }

@ -384,7 +384,8 @@ class PDF
$returnHtml = false, $returnHtml = false,
$addDefaultCss = false, $addDefaultCss = false,
$completeHeader = true, $completeHeader = true,
$disableFooter = false $disableFooter = false,
$disablePagination = false
) { ) {
$urlAppend = ''; $urlAppend = '';
@ -400,7 +401,7 @@ class PDF
// Formatting the pdf // Formatting the pdf
$courseInfo = api_get_course_info($courseCode); $courseInfo = api_get_course_info($courseCode);
self::format_pdf($courseInfo, $completeHeader); self::format_pdf($courseInfo, $completeHeader, $disablePagination);
$document_html = preg_replace($clean_search, '', $document_html); $document_html = preg_replace($clean_search, '', $document_html);
//absolute path for frames.css //TODO: necessary? //absolute path for frames.css //TODO: necessary?
@ -476,8 +477,6 @@ class PDF
if ($addDefaultCss) { if ($addDefaultCss) {
$basicStyles = [ $basicStyles = [
//api_get_bootstrap_and_font_awesome(true, true),
//api_get_path(SYS_PUBLIC_PATH).'build/css/app.css',
api_get_path(SYS_PUBLIC_PATH).'build/css/themes/'.api_get_visual_theme().'/default.css', api_get_path(SYS_PUBLIC_PATH).'build/css/themes/'.api_get_visual_theme().'/default.css',
]; ];
foreach ($basicStyles as $style) { foreach ($basicStyles as $style) {
@ -730,23 +729,15 @@ class PDF
* @param array $courseInfo General course information (to fill headers) * @param array $courseInfo General course information (to fill headers)
* @param bool $complete Whether we want headers, footers and watermark or not * @param bool $complete Whether we want headers, footers and watermark or not
*/ */
public function format_pdf($courseInfo, $complete = true) public function format_pdf($courseInfo, $complete = true, $disablePagination = false)
{ {
$courseCode = null; $courseCode = null;
if (!empty($courseInfo)) { if (!empty($courseInfo)) {
$courseCode = $courseInfo['code']; $courseCode = $courseInfo['code'];
} }
/*$pdf->SetAuthor('Documents Chamilo');
$pdf->SetTitle('title');
$pdf->SetSubject('Exported from Chamilo Documents');
$pdf->SetKeywords('Chamilo Documents');
*/
// TODO: To be read from the html document.
$this->pdf->directionality = api_get_text_direction(); $this->pdf->directionality = api_get_text_direction();
//$this->pdf->useOnlyCoreFonts = true;
$this->pdf->onlyCoreFonts = true; $this->pdf->onlyCoreFonts = true;
// Use different Odd/Even headers and footers and mirror margins
$this->pdf->mirrorMargins = 1; $this->pdf->mirrorMargins = 1;
// Add decoration only if not stated otherwise // Add decoration only if not stated otherwise
@ -755,7 +746,6 @@ class PDF
if ('true' == api_get_setting('pdf_export_watermark_enable')) { if ('true' == api_get_setting('pdf_export_watermark_enable')) {
$watermark_file = self::get_watermark($courseCode); $watermark_file = self::get_watermark($courseCode);
if ($watermark_file) { if ($watermark_file) {
//http://mpdf1.com/manual/index.php?tid=269&searchstring=watermark
$this->pdf->SetWatermarkImage($watermark_file); $this->pdf->SetWatermarkImage($watermark_file);
$this->pdf->showWatermarkImage = true; $this->pdf->showWatermarkImage = true;
} else { } else {
@ -781,6 +771,10 @@ class PDF
} }
} }
if ($disablePagination) {
$this->pdf->SetHTMLHeader('');
$this->pdf->SetHTMLFooter('');
} else {
if (empty($this->custom_header)) { if (empty($this->custom_header)) {
self::set_header($courseInfo); self::set_header($courseInfo);
} else { } else {
@ -795,6 +789,7 @@ class PDF
} }
} }
} }
}
/** /**
* Generate a PDF file from $html in SYS_APP_PATH. * Generate a PDF file from $html in SYS_APP_PATH.

Loading…
Cancel
Save