Skip to content

Commit

Permalink
Fix export pdf BT#17455
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Jun 24, 2020
1 parent c04e689 commit 8978961
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main/inc/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,14 @@ public function content_to_pdf(
api_get_path(SYS_CODE_PATH).'img/',
$document_html
);

$theme = api_get_visual_theme();
$document_html = str_replace(
api_get_path(WEB_CSS_PATH).'themes/'.$theme,
api_get_path(SYS_CSS_PATH).'themes/'.$theme,
$document_html
);

$document_html = str_replace(api_get_path(WEB_ARCHIVE_PATH), api_get_path(SYS_ARCHIVE_PATH), $document_html);

// The library mPDF expects UTF-8 encoded input data.
Expand All @@ -500,7 +508,7 @@ public function content_to_pdf(

$cssBootstrap = file_get_contents(api_get_path(SYS_PATH).'web/assets/bootstrap/dist/css/bootstrap.min.css');
if ($addDefaultCss) {
$css_file = api_get_path(SYS_CSS_PATH).'themes/'.api_get_visual_theme().'/print.css';
$css_file = api_get_path(SYS_CSS_PATH).'themes/'.$theme.'/print.css';
if (!file_exists($css_file)) {
$css_file = api_get_path(SYS_CSS_PATH).'/print.css';
}
Expand All @@ -526,13 +534,12 @@ public function content_to_pdf(
$output_file = $pdf_name.'.pdf';
}

if ($outputMode == 'F') {
if ($outputMode === 'F') {
$output_file = api_get_path(SYS_ARCHIVE_PATH).$output_file;
}

if ($saveInFile) {
$fileToSave = !empty($fileToSave) ? $fileToSave : api_get_path(SYS_ARCHIVE_PATH).uniqid();

@$this->pdf->Output(
$fileToSave,
$outputMode
Expand Down

0 comments on commit 8978961

Please sign in to comment.