4

I am using tcpdf to create a pdf, but it cant show chinese character, instead it just show square box. I used this example that provided by them and then changed the cache/utf8test.txt to chinese character but it show "square box". How am I solve this?

Sehdev
  • 5,486
  • 3
  • 11
  • 34
Negolas
  • 41
  • 1
  • 1
  • 2

5 Answers5

10

You need to use unicode supporting font, like you can use stsongstdlight font for chinese. Hope it helps

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
  • Copied from here https://raw.githubusercontent.com/alchemy-fr/tcpdf/master/fonts/stsongstdlight.php and placed in `fonts` directory. Japanese and Chinese fonts ok. But do not see Korean fonts, not good for Russian, and do not see some Latvian fonts. Idea to unify/change `$cw = array...` in `stsongstdlight.php` May be someone already has a solution and can advise me? – user2360831 Sep 28 '20 at 04:12
8

try this

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

It just helped me. Hope it also helps u.

early
  • 543
  • 7
  • 14
3

I found this copy all files to tcpdf/fonts and now I can just use it with $pdf->SetFont('DroidSansFallback', '', 8, '', false);

  • https://github.com/jenskutilek/free-fonts/blob/master/Droid/Droid%20Sans%20Fallback/DroidSansFallback.ttf I think there's also DroidSansFallback Full version – Timo Huovinen Dec 27 '18 at 13:02
2

I managed to get it to work with the Arial Unicode font.

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

Only issue is it's $165 http://www.fonts.com/font/ascender/arial-unicode

Ben Sinclair
  • 3,896
  • 7
  • 54
  • 94
  • This is a great font, but it has two major drawbacks: first is not free, as you stated, and second there are no bold, italic, and other variants available. – gog Feb 22 '21 at 15:55
0

I am using the following code to display both Traditional and Simplified Chinese chars.

$pdf->SetFont('msungstdlight','',10);