writeHTML($content, false) $htm...">

Having HTML2PDF encoded æøå characters

$content = "ÆØÅ";
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->writeHTML($content, false)

$html2pdf->Output('', 'S'));

Gives me a pdf file with "Ã † Ã ~ Ã"

I checked the encoding in html2pdf.class.php and it is set to UTF-8, which should be accurate.

I tried changing 'en' to 'da' (Danish), all the same result.

How can i fix this? Spent hours now look ..

+5
source share
3 answers

It looks like you are specifying the wrong encoding of the output. The conclusion is typical of what you get if you try to show the output of UTF-8 as ISO8859-1, for example.

It looks like the HTML2PDF constructor also has a version that accepts character encoding as a parameter:

$html2pdf = new HTML2PDF('P','A4','da', true, 'UTF-8');

can work...

+1
source

PHP

utf8_decode($article_content);

, str_replace()

$content = "ÆØÅ"; 
$code_html = array("Æ","Ø","Å");
$caract_sp = array("Æ","Ø","Å");
str_replace($code_html, $caract_sp, $content);

: http://www.toutimages.com/codes_caracteres.htm

+1

, UTF8 html2pdf:

  • "UTF-8" , Erik
  • UTF-8 html2pdf: freeserif

, :)

+1

All Articles