DaDaBIK
This forum is devoted to the discussion about the software DaDaBIK database front-end
the PHP Database application generator for MySQL, PostgreSQL and SQLite; also available for Wordpress.

Welcome! Log In Create A New Profile

Advanced

Export to PDF - UTF-8 character wrong output

Posted by Miro 
Export to PDF - UTF-8 character wrong output
April 14, 2018 01:01AM
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
Re: Export to PDF - UTF-8 character wrong output
April 16, 2018 12:51AM
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,

________________________________________________________
Eugenio |\.-./| DaDaBIK developer and project admin
Re: Export to PDF - UTF-8 character wrong output
April 16, 2018 11:17PM
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.
Re: Export to PDF - UTF-8 character wrong output
April 17, 2018 01:26AM
Perfect!

________________________________________________________
Eugenio |\.-./| DaDaBIK developer and project admin
Re: Export to PDF - UTF-8 character wrong output
September 16, 2018 05:17AM
i did that but it didnt not work !
Re: Export to PDF - UTF-8 character wrong output
September 16, 2018 06:08AM
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
Re: Export to PDF - UTF-8 character wrong output
September 16, 2018 01:55PM
a different set of fonts worked with me

aealarabiya.ctg
Re: Export to PDF - UTF-8 character wrong output
September 17, 2018 12:55AM
Hello,
so is it working now?

________________________________________________________
Eugenio |\.-./| DaDaBIK developer and project admin
Re: Export to PDF - UTF-8 character wrong output
September 17, 2018 01:37AM
Yes with this font it is
Sorry, only registered users may post in this forum.

Click here to login