问题
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.
回答1:
Try mPDF as an alternative. It is very good and easy to use. Here is an example of how it displays Hindi
回答2:
I would try mpdf1.com I have tried it before, and it worked with hindi
回答3:
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');
回答4:
Try this, it works.
$mpdf->SetAutoFont();
来源:https://stackoverflow.com/questions/13524132/hindi-language-not-displaying-correctly-on-tcpdf