Search code examples
phppdfmpdf

How to print tamil letters in pdf when using mpdf?


I'm using mpdf to convert pdf conversion from html.

I'm trying to print the following

$html = '<table  style = "width:300px;border-collapse: collapse;border: 1px solid black;">
            <tr style ="border: 1px solid black;">
                <td style = "border: 1px solid black;padding: 20px;text-align:center;">test</td>
                <td style = "border: 1px solid black;padding: 20px;text-align:center;">ராசி</td>
                <td style = "border: 1px solid black;padding: 20px;text-align:center;">ராசி</td>
                <td style = "border: 1px solid black;padding: 20px;text-align:center;">test</td>
            </tr>
</table>';
        $html = utf8_encode($html);
        $mpdf=new mPDF();
        $mpdf->WriteHTML($html);
        $mpdf->Output();

I could be able to the document. But the tamil text is not able to print. It looks unreadable in pdf document. What I want to do to get the tamil letters be printed? I tried encoding the html, but in vain.


Solution

  • I did it by including tamil font file ind_ta_1_001.ttf into 'ttfonts' folder and then to call it to pdf changed the code as below

        $mpdf=new mPDF('ta');
        $mpdf->WriteHTML($html);
        $mpdf->Output();
    

    It worked fine since mpdf supports for tamil language.