Jump to content

Generated PDF and CSV cannot display UTF-8 content


Krid.Ji

Recommended Posts

Dear community,

 

I have started to use prestashop for create marketplace. But there are few issues that occurred to user.

For example, when customer placed their order in the system. But the address text (Thai language) cannot render on invoice PDF and exported orders (see attached).

The database charset and collation are support UTF-8, so on website, the text can display flawlessly.

Any suggestion of configuration to proceed?

PS. I need to opt-out the Thai language as web, because SEO plays tricks with url/th/[some_translated_text_that_fail_to_go_home]

 

Best regards,

Krid Ji

 

 

 

Screen Shot 2564-08-04 at 14.43.50.png

Screen Shot 2564-08-04 at 14.54.46.png

Edited by Krid.Ji
Censor some info from screenshot (see edit history)
Link to comment
Share on other sites

3 hours ago, SmartDataSoft said:

Hello, which version of PrestaShop you are using. and what is the php version of your hosting.

Thank you

Hi,

I'm using Prestashop version 1.7.7.5, and PHP is 7.3.28

Thanks!

Link to comment
Share on other sites

Hi,

Thank you for your response, but I have checked my database. And both charset and collation are utf8 and utf8_general_ci since beginning.

But the result still show as the original question post.

Do you know where should I look to solve this issue?

Best regards

Screen Shot 2564-08-06 at 21.51.56.png

Link to comment
Share on other sites

@Krid.Ji


For you i finally able to solve the issue.  Open this file /1.7.7.0/classes/pdf/PDFGenerator.php  line no  32

const DEFAULT_FONT = 'freeserif'; 

set this font in place of  

const DEFAULT_FONT = 'helvetica';  

then  same file  line 

138 function  setFontForLang   comment first 5 line and put the last line and then check it will show like this image 

// if (array_key_exists($iso_lang, $this->font_by_lang)) {

// $this->font = $this->font_by_lang[$iso_lang];

// } else {

// $this->font = self::DEFAULT_FONT;

// }

$this->font = self::DEFAULT_FONT;

 

N.B: In my case i have to comment this 5 line, because when i print invoice from back end the code is missing. you can check from customer front end without comment this 5 line, if pdf print fine. only the first change that is fine. The code describe, the pdf add font depand on customer langauge. You can set the default font to  freeserif for thai

 

Thank you

Screenshot 2021-08-06 at 11.57.24 PM.png

Edited by SmartDataSoft (see edit history)
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...