Printing issue with Hindi Unicode on Windows and Ubuntu both

I am working with Hindi Text on pdf. Though Hindi text is generating but its showing as misplaced matras. Suppose I have word like 'ज़िन्दगी' but its showing as

If I copy this text and paste on Libre Office Writer then it prints correct. I have tried nearly two fonts with tcpdf. Arial Unicode MS as well as Lohit_hi

$tcpdf->SetFont('arialuni', 'B', 15, 'false');
$html = nl2br($result['Song']['hindi']);
$tcpdf->writeHTMLCell(0, 20, 20, 25, $html);

Why its showing character but misplaced their position.


If I copy and paste 'ज़िन्दगी' into microsoft word, by default, it shows like this:

It's actually the exact same string of unicode characters (that is, a िन followed by a virama, followed by a द), but it's just rendered in different ways, depending on the font. Unicode fonts have complex logic for deciding when to substitute a certain string of characters for a different glyph, and the font being used by your PDF doesn't support the particular substitution you want.

You just have to find a font that does support that substitution, and make sure that your PDF is using that font. (It might be the case that your current setFont call isn't working correctly, or the font you specify isn't available at the time you set it, so it uses the system's default font for hindi characters, which doesn't support the substitution you're referring to).


Why aren't you using writeHTML() instead of writeHTMLCell() ? Your problem correlates obviously with the cell. Looks a like the line height is wrong or even there is the CSS attribute for background repeat is set (should be background-repeat:none; ). writeHTML() would prevent this.


I do not believe TCPDF can properly render Hindi script. The fonts alone are not enough to render complex scripts. The following quote is an excerpt from a comment thread regarding rendering Saurashtra text in TCPDF. This likely applies to Hindi as well. Malayalam and Gujarati can't be rendered in TCPDF either as far as I'm aware.

[Re: Rendering Saurashtra text in TCPDF] [...] For TCPDF, the true type font need to be converted to afm format first, then for each script, the diacritics or ligature rules are implemented in tcpdf itself. [...] Fonts are not enough for rendering, a shaping engine is also required for complex script to interpret the glyph formation rules. This is what PyPDFLib is trying to solve by using Pango for script rendering and Cairo for graphics. Santosh -- Comment on creating a new Language ecosystem- Sourashtra as example

The example for mPDF appears to demonstrate functional Hindi, as referenced on an answer for this question: Hindi language not displaying correctly on tcpdf

链接地址: http://www.djcxy.com/p/15638.html

上一篇: Google应用引擎开发者

下一篇: 在Windows和Ubuntu上都使用印地文Unicode打印问题