0

By using laravel-pdf, I am trying to make print page which includes Korean. Html view page works fine but once converted it to pdf and stream, Only Korean part shows like ????

  • controller
    namespace App\Http\Controllers;
    
    use App\Http\Controllers\Controller;
    use PDF;
    
    class TestController extends Controller
    {
        public function pdf(){
            $pdf = PDF::loadView('pdf_view2');
            return $pdf->stream();
        }
        public function html(){
            return view('pdf_view2');
        }
    }
  • blade
    <!DOCTYPE html>
    <html lang="ko">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style>
            @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;500;700;900&family=Open+Sans&family=Roboto&family=Single+Day&display=swap');
            * {
                font-family: 'Noto Sans KR', sans-serif;
                font-family: 'Open Sans', sans-serif;
                font-family: 'Roboto', sans-serif;
                font-family: 'Single Day', cursive;
            }
        </style>
    </head>
    <body>
        <div>
            <h2>Hello, world~!</h2>
            <h1>안녕 세상아~~!</h1>
        </div>
    </body>
    </html>

*output [html vs pdf] [1]: https://i.stack.imgur.com/aXJny.png

jayk
  • 1
  • 1
  • you need to install proper fonts to show Korean language. – atikur rahman Sep 20 '21 at 07:49
  • you should add korean font. @font-face { font-family: cedarville-font-family; src: url("{{ asset('fonts/Cedarville-Cursive.ttf') }}"); font-weight: normal; } – Syamlal Sep 20 '21 at 10:09
  • 1
    @syamlal thank you for your answer. I did your code with korean font 'dokdo.ttf' which is stored in folder 'public/fonts'. It doesn't work with PDF either. this repository is https://github.com/kimjingo/laravel-dompdf-korean – jayk Sep 20 '21 at 23:41

1 Answers1

0

Looks like a character encoding issue, most likely an issue with an incompatible font or the character encoding not being specified. Various troubleshooting steps have been posted to this thread: dompdf character encoding UTF-8

ItsGageH
  • 385
  • 1
  • 9