Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set mpdf HTML contains invalid UTF-8 character(s)

Tags:

php

pdf

how to set mpdf HTML contains invalid UTF-8 character(s) when you create pdf on your appliactions

like image 872
debasish Avatar asked Feb 26 '15 06:02

debasish


2 Answers

Try this

$html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');

before calling: "$mpdf->WriteHTML($html);"

It's seems senseless, but it works for me.

like image 79
MoxFulder Avatar answered Sep 16 '22 12:09

MoxFulder


The below two lines will do the trick

$mpdf->allow_charset_conversion = true;
$mpdf->charset_in = 'iso-8859-4';

Add the above two lines after creating the object , this will look like

$mpdf=new mPDF();
$mpdf->allow_charset_conversion = true;
$mpdf->charset_in = 'iso-8859-4';
like image 27
user3408779 Avatar answered Sep 18 '22 12:09

user3408779