Hindi language not displaying correctly on tcpdf
Asked Answered
W

4

14

i have created below code for displaying hindi text using arial unicode font in tcpdf

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);


//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

$pdf->addTTFfont('fonts/ARIALUNI.TTF', 'TrueTypeUnicode', '', 32);
$pdf->SetFont('arialuni', '', 10,'false');

$txt = 'hindi text with arial unicode समृध्दि';

$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('example_038.pdf', 'I');

but it is not getting displayed properly

But in php it showing correct text.

Please tell me if there is anything wrong.

Wish answered 23/11, 2012 at 6:31 Comment(7)
so i don't understand. if code works.. where is the problem???Dysuria
You should add that it is being displayed differently.Delacourt
i want to print समृध्दि t this hindi text but it not showing exactly same in pdf. this is the problemWish
In my PDF reader I can find this word in text using search with "समृध्दि". Looks like everything is okKm
it seems tcpdf is not recognizing utf characters properly. समृध्दि is a bit complex word try using simple utf8 words. or try different combination on google.com/transliterate/indic try writing in hindi, marathi and other devnagri fonts, something may workAuthorship
i have got solution, now i used MPDF for this, its working fine. example link -: mpdf1.com/examples/example_utf8.pdfWish
You should let TCPDF know :)Jaf
J
2

Try mPDF as an alternative. It is very good and easy to use. Here is an example of how it displays Hindi

Junk answered 5/12, 2012 at 15:15 Comment(0)
S
0

I would try mpdf1.com I have tried it before, and it worked with hindi

Saith answered 28/12, 2012 at 17:4 Comment(0)
S
-1

Something could be wrong with the font.

Try replacing the following lines and trying another font:

$pdf->addTTFfont('fonts/ARIALUNI.TTF', 'TrueTypeUnicode', '', 32);
$pdf->SetFont('arialuni', '', 10,'false');
Saturn answered 30/12, 2012 at 11:30 Comment(0)
N
-1

Try this, it works.

$mpdf->SetAutoFont();

Nightwalker answered 25/7, 2014 at 20:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.