0

I am trying to display Tamil content in PDF format using TFPDF. I have downloaded TSCu_SaiIndira.ttf, a Tamil font and stored it in the path C:\wamp\www\tfpdf\font\unifont. The Tamil word stored in Notepad is 'பெயர்கள்'. When I run the code below, it is printed with different letters

<?php
require('tfpdf.php');

$pdf = new tFPDF();
$pdf->AddPage();

// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','TSCu_SaiIndira.ttf',true);
$pdf->SetFont('DejaVu','',14);

// Load a UTF-8 string from a file and print it
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);

// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 12 KB.');

$pdf->Output();
?>

I am new to coding. I've read all the answers posted for the relevant questions but nothing is working out.

dda
  • 6,030
  • 2
  • 25
  • 34
manikandan
  • 139
  • 1
  • 2
  • 15

1 Answers1

0

In this code:

$pdf->AddFont('DejaVu','','TSCu_SaiIndira.ttf',true);
$pdf->SetFont('DejaVu','',14);

You are using 'DejaVu' as the font family name, which isn't right. I did a quick test, and:

$pdf->AddFont('TSCu_SaiIndira','','TSCu_SaiIndira.ttf', true);
$pdf->SetFont('TSCu_SaiIndira','',14);

Worked for me.

dda
  • 6,030
  • 2
  • 25
  • 34