Prestashop 1.6: PDF invoice encoding issues for Chinese language

File to change is located at classes\pdf\PDFGenerator.php
Generally:
Change helvetica font.
Delete useless languages, leave only ‘zh’ => ‘cid0cs’,
Change encoding.
Than on English language documents Chinese characters are displayed correctly (address, names, etc….)
Probably it works for other languages too.

Source: https://www.prestashop.com/forums/topic/336709-presta-15-cant-display-chinese-characters-in-pdf-documents/?p=1702105

class PDFGeneratorCore extends TCPDF
{
const DEFAULT_FONT = 'helvetica';

public $header;
public $footer;
public $content;
public $font;

public $font_by_lang = array(
‘ja’ => ‘cid0jp’,
‘bg’ => ‘freeserif’,
‘ru’ => ‘freeserif’,
‘uk’ => ‘freeserif’,
‘mk’ => ‘freeserif’,
‘el’ => ‘freeserif’,
‘en’ => ‘dejavusans’,
‘vn’ => ‘dejavusans’,
‘pl’ => ‘dejavusans’,
‘ar’ => ‘dejavusans’,
‘fa’ => ‘dejavusans’,
‘ur’ => ‘dejavusans’,
‘az’ => ‘dejavusans’,
‘ca’ => ‘dejavusans’,
‘gl’ => ‘dejavusans’,
‘hr’ => ‘dejavusans’,
‘sr’ => ‘dejavusans’,
‘si’ => ‘dejavusans’,
‘cs’ => ‘dejavusans’,
‘sk’ => ‘dejavusans’,
‘ka’ => ‘dejavusans’,
‘he’ => ‘dejavusans’,
‘lo’ => ‘dejavusans’,
‘lv’ => ‘dejavusans’,
‘tr’ => ‘dejavusans’,
‘ko’ => ‘cid0kr’,
‘zh’ => ‘cid0cs’,
‘tw’ => ‘cid0cs’,
‘th’ => ‘freeserif’
);


public function __construct($use_cache = false)
{
parent::__construct('P', 'mm', 'A4', true, 'UTF-8', $use_cache, false);
$this->setRTL(Context::getContext()->language->is_rtl);
}

Than change it like this:


class PDFGeneratorCore extends TCPDF
{
const DEFAULT_FONT = 'cid0cs';

public $header;
public $footer;
public $content;
public $font;

public $font_by_lang = array(

‘zh’ => ‘cid0cs’

);


public function __construct($use_cache = false)
{
parent::__construct('P', 'mm', 'A4', true, 'gb2312', $use_cache, false);
$this->setRTL(Context::getContext()->language->is_rtl);
}

This entry was posted in ecommerce and tagged . Bookmark the permalink.