tags:

views:

102

answers:

1

Im creating a PDF document with ezPDF (version 0.9).

The data I insert in the document is from a MySQL database with encoding: "latin1_swedish_ci".

Special characters (especially ö, which matters the most now) are displayed like Greek pre historical algabra (literal) in the document.

What I have tried so far:

iconv();
htmlspecialchars();
htmlentities();
mb_convert_encoding();
utf8_encode();
include with chr(148);
mb_detect_encoding() returns 'UTF-8';

All of these wont work, the character is either not displayed or has a strange markup.

What else can I try?

UPDATE: Downloaded the new version, problem still remains: See here: alt text

A: 

Are you fetching the data from MySQL as UTF-8? If not,it might be double-encoded already in that step before passing it to the PDF generator?

Have you tried?

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
mysql_set_charset('utf8',$link);

Edit: Oh sorry, I misunderstood. BUT, beware, the content in the DB might be utf-8 encoded or encoded in any other format no matter what you have set the database to supposedly contain.

Can you show us exactly what characters you get at the various steps?

Edit2:

I downloaded: http://www.ros.co.nz/pdf/downloads.php?f=pdfClassesAndFonts_009e.zip from http://www.ros.co.nz/pdf/

and run this script in the same dir I unpacked the zip:

<?php
include 'class.ezpdf.php';
$pdf = new Cezpdf('a4','portrait');
$pdf->ezText("\xf6\n",0,array('justification'=>'centre'));
$pdf->ezStream();
?>

and get a proper ö in the document at least.

if like you said the detected encoding is utf-8, try wrapping a utf8_decode around it:

<?php
include 'class.ezpdf.php';
$pdf = new Cezpdf('a4','portrait');
$pdf->ezText(utf8_decode("\xc3\xb6\n"),0,array('justification'=>'centre'));
$pdf->ezStream();
?>

If it still doesn't work, maybe you have an older version of ezpdf? It seems they did had to add some fixes for non-ascii characters throughout the times, although long ago.

nicomen
In phpmyadmin the ö is displayed rightIn a var_dump: �In the PDF itself: its a ^
Johan
bump, just to notify I have edited the answer...
nicomen
Downloaded the new version, problem still remains:See here: http://i55.tinypic.com/r1hfnd.jpgHope this helps.
Johan