laravel-dompdf thai language not working Hello Guys,
I'm using barryvdh/laravel-dompdf version 0.8.6. When i'm trying to print THAI language, instead of showing thai text it is showing ????? . I tried with font THSarabunNew.ttf but doesn't work. This is my code -
ROUTE -
Route::get('/print', function () {
$pdf = PDF::loadView('print');
return @$pdf->stream();
})->name('print');
VIEW (print.blade.php)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Laravel</title>
<style>
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: normal;
src: url("{{ asset('fonts/THSarabunNew.ttf') }}") format('truetype');
}
body {
font-family: 'THSarabunNew';
}
</style>
</head>
<body>
<h1>
แดชบอร์ด
</h1>
</body>
</html>
Any suggestion would be highly appreciated.
Yes, I tried but didn't work.
For your information, i have copied /fonts folder within public, resources and storage directories just in case if it works.
this is font link - http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/
And those fonts are linked correct because if i am downloading that font on button click then it is downloading means it is linked correctly, right?
Hello @sinnbeck ,
The problem is little bit weird. Text is not rendering because of h1 tag, but if i am writing same text within p or span tags, then it is working. I have 30+ pages where i am using dompdf. Any idea why it is happening.
Working code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Laravel</title>
<style>
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: normal;
src: url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNew.ttf') }}") format('truetype');
}
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: normal;
src: url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNewBold.ttf') }}") format('truetype');
}
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: normal;
src: url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNewBoldItalic.ttf') }}") format('truetype');
}
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: normal;
src: url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNewItalic.ttf') }}") format('truetype');
}
body {
font-family: 'THSarabunNew';
}
</style>
</head>
<body>
<h1>
แดชบอร์ด // not working
</h1>
<p>
แดชบอร์ด //working
</p>
</body>
</html>
That is indeed strange. Perhaps consider posting it as an issue on the github repo.
For now, a solution could be to replace the h1 tags with a styled div tag
Thank you @sinnbeck ,
It worked. This is the working code -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Laravel</title>
<style>
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: bold;
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'),url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNew.ttf') }}") format('truetype');
}
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: bold;
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNewBold.ttf') }}") format('truetype');
}
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: bold;
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNewBoldItalic.ttf') }}") format('truetype');
}
@font-face {
font-family: 'THSarabunNew';
font-style: normal;
font-weight: bold;
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url("{{ asset('http://164.115.33.174/awards_opdc/assets/fonts/THSarabunNew/THSarabunNewItalic.ttf') }}") format('truetype');
}
body {
font-family: 'THSarabunNew';
}
</style>
</head>
<body>
<h1>
แดชบอร์ด {{-- NOW WORKING --}}
</h1>
<p>
แดชบอร์ด {{-- WORKING --}}
</p>
</body>
</html>
Happy to help. Remeber to mark the thread as solved
@sinnbeck I am facing an issue with the multilanguage PDF export. I want Chinese export. But the out is ????? like this. Can you help me, please?
Please sign in or create an account to participate in this conversation.