Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dompdf-Laravel not working with Unicode character

Tags:

php

laravel

I'm using Laravel 5.5 with DOMPDF its work fine for English but not working for Unicode it's always output ???? symbol to me

Controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use PDF;

class PdfController extends Controller
{
    public function export(){
        $data['title']="Print Report";
        $pdf = PDF::loadView('pdf.invoice', $data);
        return $pdf->download('invoice.pdf');
    }
}

Blade

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <style>
        @font-face {
            font-family: khmer;
            font-style: normal;
            font-weight: 400;
            src: url({{asset('fonts/khmer.ttf')}}) format('true-type');
        }
    </style>

</head>
<body>
    កម្ពុជាក្រោម
</body>
</html>

Result ?????????

like image 552
Plan-B Avatar asked Feb 08 '18 03:02

Plan-B


1 Answers

you just need to add font-family: DejaVu Sans; in your body or also you can set the font family to any specific div in which you are going to display the Unicode Characters.

For body: body{font-family: DejaVu Sans;}

And for a specific div: <div style="font-family: DejaVu Sans;"> --- </div>

Hope this would help.

like image 51
Talha Ishtiaq Avatar answered Nov 14 '22 21:11

Talha Ishtiaq