FPDF - Mix of Chinese and English characters


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.

- 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.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

ee_autoConnect With a Mentor Commented:
Question PAQ'd and stored in the solution database.
Lukasz ChmielewskiCommented:
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

WongyAuthor Commented:

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.
WongyAuthor Commented:
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?
WongyAuthor Commented:
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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.