Solved

FPDF - Mix of Chinese and English characters

Posted on 2011-02-28
8
1,264 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
session dropped in IE 10 22
Return data with AJAX, JQUERY and PHP 13 38
Post xml via PHP Soap Client 3 15
PHP JSON Clean up 5 11
A list of useful business intelligence software.
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now