Bappy
Bappy

Reputation: 111

Laravel: DomPDF bangla language letters show as squares

I am trying to create some pdf files for an online management system using DomPDF in laravel. It is showing squares instead of bangla letters. I tried using mpdf but it acts the same. I tried to load different true type bangla fonts using @font-face but nothing seems to work, and sometimes even show question marks instead of squares. Here is how my html file looks like-

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <style type="text/css">
    body {
            margin: 0;
            font-size: 85%;
            font-family: DejaVu Sans, Times Roman;
        }
  </style>
</head>
<body>
  <p>স্টোর ম্যানেজমেন্ট সিস্টেম</p>
</body>
</html>

This is what the php code looks like

$pdf = PDF::loadView('test');
return $pdf->stream('test.pdf');

The output enter image description here

I am using mint 20 and lamp as my environment

Upvotes: 3

Views: 1743

Answers (1)

You need to add a custom font for Bengali. Follow my code, I hope it will solve your problem.

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <style type="text/css">
    body {
            margin: 0;
            font-size: 85%;
        }

        @font-face{
            font-family: "My-custom-font";
            src : url("Custom Font Name.ttf")
        }
        .custom-font{
            font: normal 20px/18px My-custom-font;
        }

  </style>
</head>
<body>
  <p class="custom-font">স্টোর ম্যানেজমেন্ট সিস্টেম</p>
</body>
</html>

Upvotes: 1

Related Questions