Jump to content

Presta 1.5 can't display Chinese characters in pdf documents.


Recommended Posts

Hello.

I found solution myself. For Presta 1,6 and 1,5

Go to Classes>Pdf>PdfGenerator.php and find this place:

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);
	}

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.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...