Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
Fixed inability to setup multiple 'fontDir' as array for Mpdf conve…
Browse files Browse the repository at this point in the history
…rter
  • Loading branch information
klimov-paul committed Feb 21, 2019
1 parent d9e4749 commit c68115b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Yii 2 HTML to PDF conversion extension Change Log
=================================================

1.0.6 under development
-----------------------

- Bug #17: Fixed inability to setup multiple 'fontDir' as array for `Mpdf` converter (klimov-paul)


1.0.5, January 24, 2019
-----------------------

Expand Down
13 changes: 11 additions & 2 deletions src/converters/Mpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ protected function convertInternal($html, $outputFileName, $options)
];

if (isset($options['fontDir'])) {
$config['fontDir'] = Yii::getAlias($options['fontDir']);
unset($options['fontDir']);
if (is_array($options['fontDir'])) {
$config['fontDir'] = array_map(['Yii', 'getAlias'], $config['fontDir']);

This comment has been minimized.

Copy link
@Slayvin

Slayvin Apr 18, 2019

I still got an error (line 48):
Undefined index: fontDir

$config['fontDir'] is not defined. Shouldn't it be $options['fontDir'] instead, in the array_map parameters ?

unset($options['fontDir']);
} else {
$options['fontDir'] = Yii::getAlias($options['fontDir']);
}
}

$pdf = new \Mpdf\Mpdf($config);

if (isset($options['fontDir'])) {
$pdf->AddFontDirectory($options['fontDir']);
unset($options['fontDir']);
}
} else {
$pdf = new \mPDF($charset, $pageSize);
}
Expand Down

0 comments on commit c68115b

Please sign in to comment.