Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/main/inc/lib/certificate.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ public function generatePdfFromCustomCertificate(): void
false,
true,
true,
true,
true
);
}
Expand Down
41 changes: 18 additions & 23 deletions public/main/inc/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ public function content_to_pdf(
$returnHtml = false,
$addDefaultCss = false,
$completeHeader = true,
$disableFooter = false
$disableFooter = false,
$disablePagination = false
) {
$urlAppend = '';

Expand All @@ -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?
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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);
}
}
}
}
Expand Down
Loading