Export to PDF - UTF-8 character wrong output

Miro

New member
You are using DaDaBIK version 8.3 Enterprise
PHP Version: 7.1.6
sqlite version: 3.8.5
Web server: Apache
Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

Hello,

I've just upgraded from version 8.1 to version 8.3 given that the "pdf export" is something that we need on regular basis. The pdf export is working fine (default template/no template), however the output PDF shows "?" characters instead of some UTF-8 characters that were supposed to be in the text eg. (čćž,...).

I've tried importing some UTF-8 fonts in the font folder of tcpdf and tried to set new UTF-8 font in "pdf_functions.php" file, but the result is still the same (just in case if the default font is not a UTF-8 font).

How can I set the pdf export to include correct UTF-8 characters in exported PDF?


Regards
Miro
 

eugenio

Administrator
Staff member
Hello,
one solution is to use a font that is able to display all the utf8 characters (the core TCPDF font used by default is not), for example freesans:

1) Download the entire TCPDF library from here: https://github.com/tecnickcom/tcpdf

2) Unzip it and look into the fonts folder

3) copy all the files related to freesans (freesans.ctg, freesans, freesansb.ctg, ....) in the include/tcpdf/fonts folder of your DaDaBIK app

4) change the font used by the default PDF template from the templates/default_header_no_template.html file changing:

font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;

to:

font-family: "freesans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;

This should fix your issue.

Let me know.

Best,
 

Miro

New member
Hello,

i've done the procedure on your instructions and it works great (in my previous attempt i didn't copy all the definition files from font folder, only the font php file).


Thanks Eugenio.
 

drashrafsabry

Well-known member
i changed the font to aealarabiya in the tcpdf font directory , it works with the no template , but if i choose one of my ttemplates , it still shows ???
how can i add the fonts to the templates i create
 
Top