/**
* @param string $orientation Values 'P' or 'L'
* @param int $mt Page top margin in mm
* @param int $mr Page right margin in mm
* @param int $mb Page bottom margin in mm
* @param int $ml Page left margin in mm
* @param int $mh Header margin in mm
* @param int $mf Footer margin in mm
*
* @return \Mpdf\Mpdf
* @throws \Mpdf\MpdfException
*/
function myPdf( string $orientation = 'P', int $mt = 40, int $mr = 10, int $mb = 20, int $ml = 10, int $mh = 8, int $mf = 8 ): \Mpdf\Mpdf {
$defaultFontConfig = ( new Mpdf\Config\FontVariables() )->getDefaults();
$fontData = $defaultFontConfig[ 'fontdata' ] + [
'homemadeapple' => [
'R' => 'HomemadeApple-Regular.ttf',
],
'jennasue' => [
'R' => 'JennaSue.ttf',
],
'kaufmann' => [
'R' => 'Kaufmann BT.ttf',
],
'roboto' => [
'R' => 'Roboto-Regular.ttf',
'I' => 'Roboto-Italic.ttf',
'B' => 'Roboto-Bold.ttf',
'BI' => 'Roboto-BoldItalic.ttf',
],
'robotocondensed' => [
'R' => 'RobotoCondensed-Regular.ttf',
'I' => 'RobotoCondensed-Italic.ttf',
'B' => 'RobotoCondensed-Bold.ttf',
'BI' => 'RobotoCondensed-BoldItalic.ttf',
],
];
$defaultConfig = ( new Mpdf\Config\ConfigVariables() )->getDefaults();
$fontDirs = $defaultConfig[ 'fontDir' ];
if ( $orientation === 'L' )
{
$return = new Mpdf\Mpdf(
[
'format' => 'A4-L',
'margin_left' => $ml,
'margin_right' => $mr,
'margin_top' => $mt,
'margin_bottom' => $mb,
'margin_header' => $mh,
'margin_footer' => $mf,
'orientation' => 'L',
'mode' => 's',
'fontDir' => array_merge( $fontDirs, [FCPATH . 'public/assets-app/fonts',] ), // path to the font files
'fontdata' => $fontData,
] );
}
else
{
$return = new Mpdf\Mpdf(
[
'format' => 'A4-P',
'margin_left' => $ml,
'margin_right' => $mr,
'margin_top' => $mt,
'margin_bottom' => $mb,
'margin_header' => $mh,
'margin_footer' => $mf,
'orientation' => 'P',
'mode' => 's',
'fontDir' => array_merge( $fontDirs, [FCPATH . 'public/assets-app/fonts',] ), // path to the font files
'fontdata' => $fontData,
] );
}
return $return;
}