8
I have a problem using mPDF. Basically, I have a code that makes a select
of a table and then displays the values in a PDF page.
The problem is that if any table value has an accent (example: "Hello") the error appears:
"HTML contains invalid UTF-8 Character(s)"
If I remove the accent, the value is displayed correctly. Is there any way to keep the accents?
Here’s my code if anyone wants to take a look:
<?php
ob_start();
?>
<html>
<head>
</head>
<body>
<?php
mysql_connect("localhost","root");
mysql_select_db("db1") or die(mysql_error());
$count=mysql_query("SELECT * FROM teste_2");
$count_fin=mysql_num_rows($count);
$x=1;
while($x<=$count_fin){
//$id = $_POST['id'];
$sql=mysql_query("SELECT questao from db1.teste_2 where id_quest=$x");
while($info = mysql_fetch_array($sql)){
$Array[$x]=$info['questao'];
}
echo $Array[$x];
echo '<hr>';
echo'<br>';
$x = $x + 1;
}
$html='<php echo $count_fin;?>'; //setcookie ("Nome_ques", "", time() - 3600); ?>
</body>
</html>
<?php
$HTMLoutput= ob_get_contents();
ob_end_clean();
//
include("mpdf/MPDF57/mpdf.php");
$mpdf=new mPDF();
$mpdf->WriteHTML($HTMLoutput);
$mpdf->Output();
?>
I thank anyone who can help.
I already found the solution. Just add $mpdf->charset_in='windows-1252';
– POP86
Put your solution with an answer stating that the MPDF needs the indication of charset in order to correctly work the values. Then mark your answer as accepted to close this topic.
– Zuul