$pdf_html variable are holding html content to add on each pdf pages. The problem is the inline font size not working. If i change it to any large font size number nothing working rather taking a default font size always. please check the below codes.
Is there anything wrong on my html deceleration? any suggestion?
Note: I have to write each html tag as absolute position which is defined on stylesheet but not inline.
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$storage_path = storage_path();
$stylesheet = file_get_contents($storage_path.'/fonts/style_pdf_custom.css');
$mpdf = new \Mpdf\Mpdf([
'dpi' => 144,
'tempDir' => $storage_path . '/app/public/documents/completed/pages',
'fontDir' => array_merge($defaultConfig['fontDir'], [
$storage_path . '/fonts'
]),
'fontdata' => $defaultFontConfig['fontdata'] + [
'greatvibes' => [
'R' => 'GreatVibes-Regular.ttf',
],
'montezregular' => [
'R' => 'Montez-Regular.ttf',
],
'sacramentoregular' => [
'R' => 'Sacramento-Regular.ttf',
]]
]);
$mpdf->WriteHTML($stylesheet,1);
foreach($available_documents as $key => $doc){
$pages = $this->appRepo->getDocumentPages($doc->id, $doc->envelope_id);
$sourceFilename = $doc->filename_system_generated;
$mpdf->SetSourceFile($storage_path . "/app/public/documents/" . $sourceFilename);
foreach($pages as $k => $page){
$elements = json_decode($page->elements);
$mpdf->AddPage();
$importedPage = $mpdf->importPage($page->page_no);
$mpdf->useTemplate($importedPage, ['adjustPageSize' => true]);
$pdf_html = '<div class="common-block" style="width:203px; left:158px;top:243px;height:28px;justify-content: left;color:black;font-size:22px;font-weight: bold; "> Mr. Admin</div><div class="common-block" style="width:247px; left:739px;top:365px;height:40px;justify-content: left;color:black;font-size:24px; ">Checking Font Size</div>';
$mpdf->WriteHTML($pdf_html, \Mpdf\HTMLParserMode::HTML_BODY);
}
}
$tempname = time().$filename;
$mpdf->Output($storage_path. "/app/public/documents/temp/" . $tempname, "F");
After doing research last couple of days i can figure out the problem why the font size not working properly inside a div with absolute position.
When your html content have absolute position and you have set a fixed height, width then what ever font-size you set it will not exceed the div and mpdf auto adjust the font-size but while on relative position any font-size always works as it define.
So finally i have adjust the div width and height then i found the actual font-size changes are working well on a div with position:absolute