tFPDF - Hindi text spelling is incorrect in pdf

Viewed 46

I want to write a hindi text in my pdf.

  • At first, I downloaded the ttf font file from google fonts

  • After that I included the ttf file inside font < unifont

  • After that, I added the fonts into my code:

    <?php
      require('tfpdf.php');
    
      $pdf = new tFPDF();
      $pdf->AddPage();
      $pdf->AddFont('NotoSerifDevanagari-Regular','','NotoSerifDevanagari-Regular.ttf',true);
      $pdf->SetFont('NotoSerifDevanagari-Regular','',10);
      $pdf->Cell(40,10,'पूसीरे के रेसुब ने नाबालिगों समेत 12 लोगों को बचाया');
      $pdf->Output();
    ?>
    

The resultant text in the pdf shows like this: screenshot of my pdf

Here, as you can see the word नाबालिगों is incorrectly spelled. Why? How do I fix this?

1 Answers

see here :

tFPDF

This class is a modified version of FPDF that adds UTF-8 support

or this :

UFPDF

that adds UTF-8 support

but you could move to TCPDF

Related