Urdu支持与php兼容的PDF库

时间:2022-10-11 21:08:01

I have used FPDF and TCPDF and both seems not to work with URDU, for instance FPDF clearly doesn't support it, but on the other hand, TCPDF supports Persian and Arabic which have same font characters as Urdu.

我使用过FPDF和TCPDF,两者似乎都不能用于URDU,例如FPDF显然不支持它,但另一方面,TCPDF支持波斯语和阿拉伯语,它们具有与乌尔都语相同的字体字符。

The problem arises when some characters are rendered properly and while others aren't using TCPDF. See the image below:

当某些字符正确呈现而其他字符未使用TCPDF时,会出现问题。见下图:

Urdu支持与php兼容的PDF库

Is there a way around TCPDF or some other library that natively supports Urdu language and is compatible with PHP.

有没有办法解决TCPDF或其他本地支持乌尔都语并且与PHP兼容的库。

Thank you!

1 个解决方案

#1


So this is what I did, I copied windows font ARIAL UNICODE MS and pasted into tcpdf/fonts/ folder.

所以这就是我做的,我复制了Windows字体ARIAL UNICODE MS并粘贴到tcpdf / fonts /文件夹中。

Then I ran following script from tcpdf/examples/

然后我从tcpdf / examples /运行以下脚本

<?php 


    require_once('tcpdf_include.php');
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $fontname = TCPDF_FONTS::addTTFfont('../fonts/ARIALUNI.ttf', 'TrueTypeUnicode', '', 32);

?>

This generated appropriate font files that could be used with TCPDF and could be used with TCPDF pdf class instance like so:

这会生成适当的字体文件,可以与TCPDF一起使用,并且可以与TCPDF pdf类实例一起使用,如下所示:

$pdf->SetFont('arialuni', '', 12);

Output:

Urdu支持与php兼容的PDF库

Now this works just as intended.

现在这正如预期的那样工作。

#1


So this is what I did, I copied windows font ARIAL UNICODE MS and pasted into tcpdf/fonts/ folder.

所以这就是我做的,我复制了Windows字体ARIAL UNICODE MS并粘贴到tcpdf / fonts /文件夹中。

Then I ran following script from tcpdf/examples/

然后我从tcpdf / examples /运行以下脚本

<?php 


    require_once('tcpdf_include.php');
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $fontname = TCPDF_FONTS::addTTFfont('../fonts/ARIALUNI.ttf', 'TrueTypeUnicode', '', 32);

?>

This generated appropriate font files that could be used with TCPDF and could be used with TCPDF pdf class instance like so:

这会生成适当的字体文件,可以与TCPDF一起使用,并且可以与TCPDF pdf类实例一起使用,如下所示:

$pdf->SetFont('arialuni', '', 12);

Output:

Urdu支持与php兼容的PDF库

Now this works just as intended.

现在这正如预期的那样工作。