Reputation: 43
I am using the barryvdh/laravel-dompdf
package and I want to create a printable page. Here is my code:
$pdf = App::make('dompdf.wrapper');
$pdf->setOptions(['dpi' => 150, 'defaultFont' => 'Arial']);
$pdf->loadHTML('
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Document</title>
</head>
<body style="font-family: Arial">
<div class="row">
<p>سلام</p>
</div>
</body>
</html>
');
return $pdf->stream();
But it does not support Arabic characters, instead displaying question marks like this:
Upvotes: 3
Views: 6845
Reputation: 81
I had same issue with any laravel PDF packages. I just found a package that solved my problem. niklasravnsborg/laravel-pdf package did it. It's easy to use and supports RTL languages such as Arabic and Persian. example:
use niklasravnsborg\LaravelPdf\Facades\Pdf;
$pdf = Pdf::loadView('pdf.invoice-view', [
'var1' => $var1,
'var2' => $var2
], [], [
'title' => 'Certificate',
'format' => 'A4-P',
'orientation' => 'P'
]);
return $pdf->stream('document.pdf');
you can add this package to your laravel project using this command:
composer require niklasravnsborg/laravel-pdf
Documentations HERE.
Upvotes: 1
Reputation: 804
Tip: UTF-8 support In your templates, set the UTF-8 Metatag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
Upvotes: 0