Search code examples
laraveldompdf

Dompdf UT8 with database records with accents


I have a problem with utf8 with my stored data with dompdf for laravel: https://github.com/barryvdh/laravel-dompdf

My column collation is set to

utf8mb4_unicode_ci

In my html file I use:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

So when I write in my html file : éééé and I generate the PDF it's file but when I display my stored data the accents are displayed by : ?

enter image description here

In my config/dompdf.php

I have set :

  "DOMPDF_UNICODE_ENABLED" => true,
  "DOMPDF_PDF_BACKEND" => "CPDF",

What am I doing wrong? The problem only come from my stored data.. Hope someone could help thanks a lot in advance.

When I display my blade page without dompdf on firefox it's also really strange I get spaces between the accents :

enter image description here

But with Chrome all is fine ..

enter image description here

Also when i trie to pass a variable with a accent to my dompdf view the content of the variable is not display when there is an accent

$fede = 'fé'; // not display 
$fede = 'fe'; // is displayed as well.. 

Solution

  • I had same issue before , and i changed many things but i couldn't make it to work , then i switched to niklasravnsborg/laravel-pdf and it worked like sharm , give it a try and see