There may be some errors due to language ;)))
I rebuilt css and pdf layouts with the latest version on local computer
Hassle-free awesome PDF created just the way I wanted it
On remote server same version creates PDF with same files but css file does not work
The below code does not need it on local computer but needs it on remote server
$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new \Mpdf\Mpdf([
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/ttfonts',
]),
'fontdata' => $fontData + [
'frutiger' => [
'R' => 'Roboto-Regular.ttf',
'I' => 'Roboto-Regular.ttf',
]
],
'default_font' => 'frutiger',
'default_font_size' => 8,
'tempDir' => __DIR__ . '/tmp'
]);
I can’t understand the mPDF explanations very much as they are explained with short and technical words for the developer.
There may be unnecessary and wrong things in this css code because it is a beginner’s work.
table.customTable {
width: 793px;
background-color: #FFFFFF;
border-collapse: collapse;
border-color: #77EEAA;
border-style: solid;
font-family: Arial;
font-size: 7pt;
font-family: Roboto, sans-serif;
}
table.customTable tr td {
padding: 5px;
border-bottom: 1px solid #ddd;
font-family:'Roboto-thin',sans-serif;
}
table.customTable tr th {
background-color: #1570cd;
color: #ffffff;
padding: 5px;
font-family:'Roboto-thin',sans-serif;
}
.align-left {
text-align:left;
}
.align-right {
text-align:right;
}
.align-center {
text-align:center;
}
.bold {
font-weight:bold;
}
.red {
color:rgb(255, 0, 0);
}
I load the CSS file as follows
$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1; // Use values in classes/ucdn.php 1 = LATIN
$mpdf->autoLangToFont = true;
$stylesheet = file_get_contents('style.css');
$mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);
$mpdf->WriteHTML($html,\Mpdf\HTMLParserMode::HTML_BODY);