2

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.

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

enter image description here

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

Thank you!

Ayub
  • 510
  • 2
  • 6
  • 21
  • 1
    There is a multi-byte variant of FPDF known as MBFPDF that might work? I normally see it used for Japanese characters, unsure about Urdu. – Muhammad Abdul-Rahim May 13 '15 at 12:27
  • @MariM I am not sure, but I ended up doing some font conversions which worked fine for me, please see the answer. – Ayub May 14 '15 at 06:16

1 Answers1

1

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

Then I ran following script from 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:

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

Output:

enter image description here

Now this works just as intended.

Ayub
  • 510
  • 2
  • 6
  • 21