2

I cannot get TCPDF display any chinese character no matter what font I am using.

I crawled and searched everywhere I could, including these interesting posts

tcpdf-utf-8-problem
tcpdf-encode-chinese-character

but still without success.

The sample #7 from TCPDF works well with a lot of different characters sets but if I add some Chinese to the text it will display as squares and the strangest thing is if I change the font to stsongstdlight as suggested in one message the text won't display at all - but the header will.

The sample #38 from TCPDF with Japanese font doesn't work either. Thanks for any advice that could let me find new ideas to try.

Community
  • 1
  • 1
CedSha
  • 149
  • 2
  • 12
  • Did you try it with Arial Unicode? http://stackoverflow.com/questions/14379119/how-to-generate-multilangual-content-pdf-in-php/14455940#14455940 – devOp Jan 22 '13 at 10:08
  • Yes please refer to the last answer of this thread... – CedSha Jan 24 '13 at 05:19

2 Answers2

5

I just tested setting the font like

$pdf->SetFont('kozminproregular', '', 12);

as suggested in tcpdf encode chinese character and it seemed to work fine.

Here is the sample from my output:

enter image description here

Community
  • 1
  • 1
BudwiseЯ
  • 1,846
  • 2
  • 16
  • 28
  • Tks for this test - This is very frustrating for me as I read several comments say they solve their problem that way....Which is not the case for me ! So now I am really stuck and do not know where to search....Would it be possible some files are corrupted in my machine ? I check kozminproregular.php but as it is only 3.5 kB I guess the fonts drawing are not there... – CedSha Oct 15 '12 at 04:46
  • By the way are you Linux or Windows user ? – CedSha Oct 15 '12 at 05:08
  • kozmin is a japanese font, you should use stsongstdlight for chinese – wdev Mar 31 '14 at 16:42
  • Thanks for this budwiser, great post!! NOTE @CedSha: Font kozminproregular also needs character set to be compatible, like UTF8 or CP950. – ekerner Apr 26 '14 at 11:33
0

Main problem is due to evince PDF reader cannot handle the CJK Chinese generated by TCPDF. after

sudo apt-get install poppler-data

Everything started to get better ! I use the font stsongstdlight which is designed for Chinese unlike the kozminproregular which looks like designed for Japanese. However I have still an issue with the spacing of non Chinese character, there is very big spaces after all T,i,u...
To solve this second issue I convert and use the fonts arialuni.ttf but this font is not open source nor free. I tried to convert many other unicode fonts which include Chinese without success.

sources :

Community
  • 1
  • 1
CedSha
  • 149
  • 2
  • 12