I have try to create pdf in Laravel. Usebarryvdh/laravel-dompdf
vendor package class. My pdf content English and Gujarati text. but gujarati content print as ?????? in pdf.
I have create pdf succesfully use this type of code pdfview is my pdf php, html content file view
view()->share('data',$data);
$pdf = PDF::loadView('pdfview');
return $pdf->stream('pdfview.pdf');
// return $pdf->download('pdfview.pdf');
I have expected to pdf content as English and Gujarati text content. Actual result in pdf Gujarati content print like ????
use wkhtmltopdf
, make sure to install all unicode library related to Gujarati language. I tried it for sinhala in ubuntu and centos.
"????" is because the font in not there by default in barryvdh/laravel-dompdf package. 1.You need to download the fonts that supports gujrati. 2.After downloading, just put the the .ttf file to your font assets folder. 3.Then use the css @font-face to explicitly declare your font supporting the gujrati characters. Just for example (using simhei.ttf). FYI, this is in my template.blade.php file
<style type="text/css">
@font-face {
font-family: SimHei;
src: url('{{base_path().'/public/report_assets/'}}fonts/simhei.ttf') format('truetype');
}
* {
font-family: SimHei;
}
</style>
<body>
//gujrati characters
.......
Thats it