Support the ongoing development of Laravel.io →
Views Laravel Configuration

I want to print pdf using bengali(Unicode) and English in same page. But got "???? ????" for bengali(unicode). Here is my code.

<!DOCTYPE html>
<html>    
<head>
<meta http-equiv="Content-Type" content="text/html;"/>
  <meta charset="UTF-8">
    <title>Title</title>
    <style> 
    @font-face {
    font-family: "kalpurush";
    font-style: normal;
    font-weight: normal;
    src: url(kalpurush.ttf) format('truetype');
}
* {
    font-family: "kalpurush";
}

</style>
</head>
<body>
<table class="table table-responsive" id="questions-table">
    <thead>
        <th>#</th>
        <th>Subject</th>
        <th>Difficulty</th>
        <th>Question</th>
        <th>Marks</th>
        <th>Status</th>        
    </thead>
    <tbody>

    @foreach($questions as $question)
        <tr>
        <td>{{Form::checkbox('id', $question->id)}}</td>
            <td>{!! $question->subject->name !!}</td>
            <td>
            @if($question->difficulty == '1')Easy
            @elseif($question->difficulty == '2')Medium
            @elseif($question->difficulty == '3')Hard
            @endif
            </td>
            <td>{!! $question->question !!}</td>
            <td>{!! $question->marks !!}</td>
            <td>{!! $question->status !!}</td>            
        </tr>
    @endforeach
    
    </tbody>
</table>
</body>
</html>


And here is how I am printing to PDF >

$question = \App\question::get();
view()->share('questions',$question);
$pdf = PDF::loadView('pdf.question');   
return $pdf->download('abc.pdf');
//return view('pdf.question')->with('questions',$question);
})->name('test');

Route::any('/test2', function(Request $request){
$pdf = PDF::loadView('pdf.question');   
return $pdf->download('htmltopdfview');

Here is the link for test file which it creates

https://ufile.io/1o6nj

Help needed. Thanks.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

debjit debjit Joined 22 Aug 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.