0

I am trying to create a pdf in the Tamil language, but I am experiencing font rendering issues. When I use the Baamini font, it works, but there is no English font in Baamini, so I tried other fonts such as latha.ttf, notosans.ttf, azaghi.ttf, and others, but these fonts do not work in tcpdf or fpdf. Please assist us in resolving this, and thank you in advance!

<?php

    header('Content-type: text/html; charset=UTF-8') ;//chrome
    require_once('tcpdf_include.php');

    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

    $pdf->setFontSubsetting(true);

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

    $pdf->AddPage();

    $utf8text = '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> </head> <body> <p>தினமும் உங்களை இந்த தோட்டத்து வழியாக செல்லும்போது என்னை கவனிப்பீர்களா என்று திரும்பி திரும்பி பார்த்து செல்வேன். ஆனால் நீங்களோ வெறி பிடித்தது போல் மண்ணை கொத்தி கொண்டிருப்பீர்கள்.</p></body></html>';

    $pdf->writeHTML($utf8text, true, 0, true, true);

    $pdf->Output('example_067.pdf', 'I');

?>

My Output is

enter image description here

Annamalai
  • 109
  • 2
  • 12
  • Related: https://stackoverflow.com/a/21530540/4688321 – kiner_shah Nov 12 '21 at 11:56
  • 1
    @kiner_shah thank for your reply, i tried these also it doesn't work for me – Annamalai Nov 12 '21 at 12:07
  • I apologize because I don't know anything about that specific language or how it should render. In the screenshot you've posted, I see glyphs, can you explain why they are incorrect? – Chris Haas Nov 12 '21 at 18:00
  • @ChrisHaas i mentioned the text (தினமும் உங்களை இந்த தோட்டத்து வழியாக செல்லும்போது என்னை கவனிப்பீர்களா என்று திரும்பி திரும்பி பார்த்து செல்வேன். ஆனால் நீங்களோ வெறி பிடித்தது போல் மண்ணை கொத்தி கொண்டிருப்பீர்கள்.) this one but the PDF library not is rendered properly. – Annamalai Dec 07 '21 at 07:21

1 Answers1

0

The damage is usually done when PDF inputs are parsed as UTF-8

enter image description here

We can see the graphics visuals are like 16 but underneath the text for search and extract is more like UTF-8

enter image description here

Now I can't say what's affecting you own sample as unseen but to use two languages you need more than one type of font, or more precisely, more than one font type. And those characters that are unconventional will actually be there but NOT as conventional text.

enter image description here

When you do that then we can expect that any well designed extractor will see both font types and convert the output to UTF-8 (Which is not normally a PDF internal font type)

தினமும் உங்களை இந்த தோட்டத்து வழியாக செல்லும்போது                                                           clear
என்னை கவனிப்பீர்களா என்று திரும்பி திரும்பி பார்த்து
செல்வேன். ஆனால் நீங்களோ வெறி பிடித்தது போல் மண்ணை
கொத்தி கொண்டிருப்பீர்கள்.

Tiṉamum uṅkaḷai inta tōṭṭattu vaḻiyāka cellumpōtu eṉṉai kavaṉippīrkaḷā eṉṟu tirumpi tirumpi pārttu celvēṉ. Āṉāl
nīṅkaḷō veṟi piṭittatu pōl maṇṇai kotti koṇṭiruppīrkaḷ.
                                                                                              178 / 5,000

Every day as I walk through this garden I will turn back to see if
you will notice me. But you will be raking the soil like a madman.
halfer
  • 19,824
  • 17
  • 99
  • 186
K J
  • 8,045
  • 3
  • 14
  • 36