Negolas
Negolas

Reputation: 41

tcpdf encode chinese character

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?

Upvotes: 4

Views: 12871

Answers (6)

Thiên Trần
Thiên Trần

Reputation: 91

It's really funny that for some files, I have to use the 'kozminproregular' font for it to work, while for others, I need to use the 'msungstdlight' font. When I use Chrome on my MacBook, there's no issue, but with Safari, there is. Customers using Windows always encounter the issue. So you should try switching between these two fonts, and then ask the customer to download and check if there are any errors.

Link download file you can ref at this: https://github.com/LazyPhper/tcpdf/blob/master/TCPDF/fonts/kozminproregular.php https://github.com/LazyPhper/tcpdf/blob/master/TCPDF/fonts/msungstdlight.php

Upvotes: 0

Vincent Cheung
Vincent Cheung

Reputation: 66

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

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

Upvotes: 0

alexgarciaguilera
alexgarciaguilera

Reputation: 41

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

Upvotes: 4

Ben Sinclair
Ben Sinclair

Reputation: 3986

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

Upvotes: 2

early
early

Reputation: 543

try this

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

It just helped me. Hope it also helps u.

Upvotes: 8

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

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

Upvotes: 10

Related Questions