Friday, November 26, 2010: Fix Thai Language Floating Tone Marks Problem in mPDF « from the old blog archive »

I am working for my school's exhibition web site, which allows students from other schools to register for various competitions and activities in the exhibition day.

At first, there was only a registration website. Later, I am informed that it should be able to generate the report as PDF file, so it could be printed and handed to the academic administration department quickly.

I searched for a PDF generation libraries and decided to use mPDF because its partial support HTML and CSS is really nice and it has UTF-8 support (the database is utf8 encoded).

All is going well, except for some floating tone marks that looks too high.

I wrote a little function that fixes this, it now looks like this:

As you see, the tone marks do not look to high anymore. Here is the code:

To use it, just before added some data to the PDF, wrap it in thai() function. For example,

$pdf->WriteHTML ($table->getHTML());


$pdf->WriteHTML (thai($table->getHTML()));

And that's it. I hope that this can be useful for some people generating PDFs with Thai language.