Solved

FPDF - Mix of Chinese and English characters

Posted on 2011-02-28
8
1,351 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:Wongy
8 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 34997032
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 34997054
0
 
LVL 1

Author Comment

by:Wongy
ID: 34997303
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.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Author Comment

by:Wongy
ID: 35018691
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!
0
 

Expert Comment

by:ruinze
ID: 35872532
how did you do it?
0
 
LVL 1

Author Comment

by:Wongy
ID: 35977195
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!
0
 

Accepted Solution

by:
ee_auto earned 0 total points
ID: 37313433
Question PAQ'd and stored in the solution database.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question