Link to home
Start Free TrialLog in
Avatar of Wongy
WongyFlag for Belgium

asked on

FPDF - Mix of Chinese and English characters

Hi,

I am generating a PDF file with PHP/FPDF. I need to be able to display Chinese and English characters at the same time.
The data are coming from a database (MySQL) where Chinese and English characters can coexist in the same field.

I can not figure out how to do that (I've searched the web for resources but none of them seem to work, or they could work if you only have Chinese characters).

An alternative would be to convert the content of the database to images and to display them in the PDF file, but I'd like to avoid this workaround.

Notes:
- in case someone has a solution, I would need step by step instructions to put it in place
- my configuration can not be changed: I have to use PHP, MySQL, FPDF.

Thank you for your help.
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Avatar of Wongy

ASKER

Hi,

Thanks for you swift reply.

I had already seen this, but the example they provide generates a blank PDF file whatever the text I enter (I have Acrobat Reader 9). I do not know why.
Also I am not sure this method can mix Chinese and English characters in the same file.
Avatar of Wongy

ASKER

I found the solution to my problem!

More details here: http://www.developpez.net/forums/d1013211/php/bibliotheques-frameworks/pdf/fpdf-mysql-multi-langues/

It works perfectly fine!
how did you do it?
Avatar of Wongy

ASKER

ruinze>
The font to use is Arialuni
- Before any query to the database, I run this: mysql_query("SET NAMES 'utf8'");
- I add the font Arialuni: $pdf->AddFont('ARIALUNI','','ARIALUNI.ttf',true);
- I set the font before displaying the text: $pdf->SetFont('ARIALUNI','',10);

That's it!
ASKER CERTIFIED SOLUTION
Avatar of ee_auto
ee_auto

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial