Solved

FPDF - Mix of Chinese and English characters

Posted on 2011-02-28
8
1,394 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

687 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