diff --git a/public/main/inc/lib/certificate.lib.php b/public/main/inc/lib/certificate.lib.php index 9f187f15a41..dbe7d2f36ef 100644 --- a/public/main/inc/lib/certificate.lib.php +++ b/public/main/inc/lib/certificate.lib.php @@ -748,6 +748,7 @@ public function generatePdfFromCustomCertificate(): void false, true, true, + true, true ); } diff --git a/public/main/inc/lib/pdf.lib.php b/public/main/inc/lib/pdf.lib.php index 766ea0101a6..e453cd81122 100644 --- a/public/main/inc/lib/pdf.lib.php +++ b/public/main/inc/lib/pdf.lib.php @@ -384,7 +384,8 @@ public function content_to_pdf( $returnHtml = false, $addDefaultCss = false, $completeHeader = true, - $disableFooter = false + $disableFooter = false, + $disablePagination = false ) { $urlAppend = ''; @@ -400,7 +401,7 @@ public function content_to_pdf( // Formatting the pdf $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); //absolute path for frames.css //TODO: necessary? @@ -476,8 +477,6 @@ public function content_to_pdf( if ($addDefaultCss) { $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', ]; foreach ($basicStyles as $style) { @@ -730,23 +729,15 @@ public function set_custom_footer($footer) * @param array $courseInfo General course information (to fill headers) * @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; if (!empty($courseInfo)) { $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->useOnlyCoreFonts = true; $this->pdf->onlyCoreFonts = true; - // Use different Odd/Even headers and footers and mirror margins $this->pdf->mirrorMargins = 1; // Add decoration only if not stated otherwise @@ -755,7 +746,6 @@ public function format_pdf($courseInfo, $complete = true) if ('true' == api_get_setting('pdf_export_watermark_enable')) { $watermark_file = self::get_watermark($courseCode); if ($watermark_file) { - //http://mpdf1.com/manual/index.php?tid=269&searchstring=watermark $this->pdf->SetWatermarkImage($watermark_file); $this->pdf->showWatermarkImage = true; } else { @@ -781,17 +771,22 @@ public function format_pdf($courseInfo, $complete = true) } } - if (empty($this->custom_header)) { - self::set_header($courseInfo); + if ($disablePagination) { + $this->pdf->SetHTMLHeader(''); + $this->pdf->SetHTMLFooter(''); } else { - $this->pdf->SetHTMLHeader($this->custom_header, 'E'); - $this->pdf->SetHTMLHeader($this->custom_header, 'O'); - } + if (empty($this->custom_header)) { + self::set_header($courseInfo); + } else { + $this->pdf->SetHTMLHeader($this->custom_header, 'E'); + $this->pdf->SetHTMLHeader($this->custom_header, 'O'); + } - if (empty($this->custom_footer)) { - self::set_footer(); - } else { - $this->pdf->SetHTMLFooter($this->custom_footer); + if (empty($this->custom_footer)) { + self::set_footer(); + } else { + $this->pdf->SetHTMLFooter($this->custom_footer); + } } } }