2

I am using tcpdf for writing PDF. I am facing weird issue with it. I am not able to write Unicode Hindi Character. 'तुम्हारे' like for this character its writing as ?????. Though I have taken UTF-8 as input.

    $tcpdf = new XTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $tcpdf->addTTFfont(K_PATH_FONTS . 'ARIALUNI.ttf', 'TrueTypeUnicode', '', 32);

Second line has created .z,.ctg,.php files. BUt still my text is outputted as ???

enter image description here

How can I write it for Hindi Unicode Characters.

Community
  • 1
  • 1
Sankalp
  • 1,300
  • 5
  • 28
  • 52

2 Answers2

1

I started using this website instead of the ->addTTFfont feature: http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf

I found this to be a much more reliable way of adding fonts to TCPDF. It will create the necessary files to drop in the folder. These are the files that would be created through the addTTFfont method.

Instructions:

  1. Visit the website found above
  2. Convert the .ttf file through this tool
  3. Save the files it gives you right to the tcpdf/fonts folder.
Joe Bergevin
  • 3,158
  • 5
  • 26
  • 34
-1

I also search for hindi font in TCPDF and found solution at last. we have to a file from : https://code.google.com/p/pyfpdf/downloads/detail?name=fpdf_unicode_font_pack.zip&can=2&q=

we don't have to include whole files. just include lohit_hi.ttf file in your fonts fonlder

and then

$pdf->addTTFfont(K_PATH_FONTS . 'lohit_ta.ttf', 'TrueTypeUnicode', '', 32); $pdf->SetFont('lohit_hi', '', 10 ,'true');

Sonu Bamniya
  • 1,095
  • 1
  • 13
  • 29
Sandy Jain
  • 91
  • 1
  • 8
  • Hey Sandy, Thanks for your help. Its also started at my end. I don't know but now I am also for adding `ArialUnicode MS`. But now problem is different. With both Arial as well as with Lohit, though its printing hindi character but characters are are properly arranged. Like `Chooti martra` apprears after character. eg. word is dil then its printing d, then choti matra then l. I hope you got problem else I will put screen shot. – Sankalp Jul 19 '13 at 05:33
  • Hey Sankalp, you are right now i got your problem. I also face same problem now and didn't get any solution. Have you got any....? – Sandy Jain Aug 02 '13 at 07:40
  • Hi @Sandy have you got any solution?? I have come accross a link that also ends with same rendering issue. Please check this. http://stackoverflow.com/questions/13569698/correcting-hindi-unicode-rendering-in-android – Sankalp Sep 01 '13 at 16:43
  • @SandyJain have you guys found any solution for improper hindi font yet? Am struggling with same issue.. – Observer Mar 08 '18 at 16:11
  • @Sankalp have you guys font solution? – Observer Mar 08 '18 at 16:11