How to fix Thai language for exported PDF file on Prestashop 1.7

Hassadee
1 min readApr 16, 2021
Prestashop 1.7’s PDFGeneratorCore Class

Hint: It’s so simple, and it’s just about font.

First place that you need to look at when you need to fix something that related to PDF, you need to go to

classes/pdf/PDFGenerator.php

And then you’ll see the default font as,

const DEFAULT_FONT = 'Helvetica';

That font is not support Thai language, all you need to do next is scroll down to find ‘th’ in the $font_by_lang array, it’s probably ‘dejavusans’ font, which is also doesn’t supports Thai language.

What you need to do is change it to ‘freeserif’ which is already in the placed as a vendor in Prestashop package with TCPDF. And this is the output,

PDF that generated from PrestaShop’s Backoffice after changed the font to ‘freeserif’

If you want to change the font to the other font, you can do by adding the font to TCPDF following this path,

/vendor/tecnickcom/tcpdf/fonts/

And about the config, you can find here, https://tcpdf.org/docs/fonts/

--

--

Hassadee

Internet Entrepreneur interested in Web3D/XR, Finance/Investment, and Software Development