【问题标题】:Is there any configurations required to show telugu unicode fonts in tcpdf?在 tcpdf 中显示泰卢固语 unicode 字体是否需要任何配置?
【发布时间】:2020-03-05 16:08:01
【问题描述】:

我必须从 php 页面生成一个 PDF,该页面包含包含 unicode 字体(泰卢固语)的 html。当我打印 html 代码并使用 TCPDF 渲染为 PDF 时,它的显示完美,Unicode 字符扭曲了字母格式。

我从谷歌翻译器那里复制了泰卢固语字体,并将泰卢固语字体添加到 tcpdf 库中。

$message = '<h2 align="center">ధన్యవాదములు -- శుభోదయం</h2>';

$fontname = $pdf->addTTFfont('E:\xampp\htdocs\ncs\svdn\flowers\tcpdf\fonts\mandali-regular.ttf', 'TrueTypeUnicode');

$pdf->SetFont($fontname, "",30, false); 

$pdf->writeHTML($message, true, 0, true, 0);

$pdf->Output("Test.pdf", 'I');

html 中的输出如下所示。并且同样必须以 PDF 格式打印。

ధన్యవాదములు -- శుభోదయం

但在当前问题中,上述辅音是不连贯的:

【问题讨论】:

  • 你有converted Mandali 用于 TCPDF 吗?

标签: php unicode fonts tcpdf


【解决方案1】:

TCPD 不支持印度语脚本工作所需的 OpenType 布局功能。

mPDF supports several indic scripts - including Telugu specifically - however,因此,如果您的项目进展不远而无法切换,那将是我的建议。

这个代码在安装mPDF with composer之后应该可以工作(虽然我没有测试过):

include 'vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
//I'm being a little lazy here and letting mPDF select the appropriate
//appropriate font.
$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1;  // Use values in classes/ucdn.php  1 = LATIN
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML('<h2 style="text-align: center;">'.
     'ధన్యవాదములు -- శుభోదయం</h2>');
$mpdf->Output('test_mpdf_lang.pdf');

【讨论】:

    猜你喜欢
    • 2014-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    • 2012-01-21
    • 2022-10-04
    • 1970-01-01
    相关资源
    最近更新 更多