Exporting HTML to PDF in a different language.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jackliu97
Forum Newbie
Posts: 4
Joined: Mon Dec 10, 2007 4:09 pm

Exporting HTML to PDF in a different language.

Post by jackliu97 »

I have a page whose label is db generated. I would like to export that page in which ever language the user wishes. Currently I have 2 languages, English and Japanese.

Its currently encoded in UTF-8 and everything displays correctly in the web browser, but displays the actual utf-8 characters when I tried to export in Japanese...

For example, you'll see things like "の契約" (minus spaces) instead of the actual Japanese characters ... の契約

Can someone please point me toward the right directions as to which PHP encoding/decoding functions I have to use to get this to work?

I tried testing the Japanese version of Yahoo.com on several html2php websites ( ie "http://www.htm2pdf.co.uk/" ) and none of them seems to be working as well.
I have also tried converting from utf-8 to several other encoding (utf-16, EUC-JP, ... ) using iconv() and outputting it via PDF_show_xy() but that did not work as well.
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: Exporting HTML to PDF in a different language.

Post by Syntac »

Try html_entity_decode(). It should make the Japanese characters display correctly, at least.
jackliu97
Forum Newbie
Posts: 4
Joined: Mon Dec 10, 2007 4:09 pm

Re: Exporting HTML to PDF in a different language.

Post by jackliu97 »

I tried using html_entity_deocde()

Code: Select all

 
 
...
 
$test_label = 'の契約';
$result = html_entity_decode($test_label, ENT_QUOTES, 'UTF-8')
PDF_show_xy($pdf, $result.": ".$order_date , SECTION_START_X+TEXT_LEFT_PADDING, 750+((SECTION_TITLE_BOX_HEIGHT-5)/2));
 
...
 
 
The PDF no longer prints out "の契約"... now its just gibberish. The PDF is probably translating the decoded entity wrong? maybe there's a adobe plug in that I'm suppose to install? I tried installing the Japanese Font Pack, but that did not work as well.
Post Reply