Wongy
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.
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.
No class link sorry, try here
http://code.google.com/p/phpjasperxml/source/browse/trunk/trunk/class/fpdf/chinese-unicode.php?spec=svn2&r=2
http://code.google.com/p/phpjasperxml/source/browse/trunk/trunk/class/fpdf/chinese-unicode.php?spec=svn2&r=2
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.
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.
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!
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?
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',' ','ARIALUN I.ttf',tru e);
- I set the font before displaying the text: $pdf->SetFont('ARIALUNI',' ',10);
That's it!
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','
- I set the font before displaying the text: $pdf->SetFont('ARIALUNI','
That's it!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://www.experts-exchange.com/questions/21485415/Display-Chinese-from-Unicode-using-FPDF.html