Hindi language not displaying correctly on tcpdf

2019-06-15 01:22发布

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.

4条回答
我命由我不由天
2楼-- · 2019-06-15 01:41

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

查看更多
萌系小妹纸
3楼-- · 2019-06-15 01:44

Try this, it works.

$mpdf->SetAutoFont();

查看更多
Explosion°爆炸
4楼-- · 2019-06-15 01:52

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');
查看更多
看我几分像从前
5楼-- · 2019-06-15 01:55

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

查看更多
登录 后发表回答