In my laravel project I am using DOMPDF to generate pdf from html blade file. I want to show text in Hindi or Gujarati as per language selection. Here is my code of controller.
$pdf=PDF::loadView('my-htmlt.pdffile',['header'=>$header,'data'=>$data,'footer'=>$footer]);
$name=$header->name."_".date('YmdHis');
if(isset($view) && $view!=''){
return $pdf->stream($name.'.pdf');
} else {
return $pdf->download($name.'.pdf');
}
Here is the code in blade file.
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{$header->name}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style type="text/css">
@page{
padding: 15px;
}
<?php if($header->lang== 'Guj'){ ?>
* {
font-family: 'noto serif gujarati', sans-serif;
}
<?php } else if($header->lang == 'Hindi'){ ?>
* {
font-family: 'tiro devanagari hindi', sans-serif;
}
<?php } ?>
</style>
<body>{{Content fetched from database either in Hindi or Gujarati}}</body>
</html>
I have downloaded ttf font files for Noto Serif Gujarati and Tiro Devnagari and copy under projectfolder/storage/fonts Folder. I have also tried using face font css with file path of ttf file. But result is same so, working with less code.
I have set collation and charset as utf8_unicode_ci in database and getting text properly from database, tested printing html view.
Now issue is that text is showing in Hindi or gujarati but text is not showing properly as per my requirement.
For example I want to show text like "ચિત્ર જોઈ તેનો પહેલો મૂળાક્ષર શોધો". But it is showing like this
Same way in hindi I want to show text like "कौन सा जीव धीमी गति से चलता है ?" But it is showing like this
Can anyone have solution to show proper text in PDF?