How can I create Malayalam PDF using TCPDF in PHP?

2020-04-19 06:30发布

问题:

I am trying to create malayalam pdfs using TCPDF. As per the manual, i had converted the fonts (using http://fonts.snm-portal.com/) and had added them. It is working but is not working correctly.

The words like 'ന്യൂഡല്ഹി, ഉത്തരവിട്ടെന്നും, എത്രയും'. are displayed as 'ന^യൂഡല്ഹി, ഉത^തരവിട^ടനെനും, എത^രയും'.

I am using 'kartika.ttf' font now and had tried some other malayalam fonts. The database, tables, fields and the site are in 'utf-8' format.

Is there any solution for this problem? Is it possible to show/save as pdf format using indian fonts?

回答1:

Scratch my last comment. As far as I've been able to find, TCPDF does not support indic scripts. For more information see the comments on this blog post http://thottingal.in/blog/2011/05/07/language-ecosystem-sourashtra/

Python's PyPDFLib http://savannah.nongnu.org/projects/pypdflib should be able to render the sample text you provided correctly however.

I wanted to test that pango, which underlies PyPDFLib, would handle the string you provided above. So I used another package built on it. I rendered it with rsvg. http://rrbits.com/malayalam.pdf [Note: The text should show up in the Kartika font, and I can't really tell if it's 100% correct due to my lack of knowledge, but I do know it's a lot closer than anything I extracted out of TCPDF. My version of pango is also ancient.]