mpdf: cannot find TTF TrueType font file

不打扰是莪最后的温柔 提交于 2019-12-13 03:39:06

问题


I'm trying to implement mpdf in CodeIgniter according to this article: http://codeigniter.com/wiki/mPDF_with_Codeigniter

I did it exactly the same way that is described there, but I got an error:

mPDF Error - cannot find TTF TrueType font file - mpdf/ttfonts/DejaVuSansCondensed.ttf

But the file is there. I tested this both on a webserver and on localhost. I changed chmod, neither did that have an effect.

What can I do about it?


回答1:


I found out what was wrong.

As recommended in the CodeIgniter Wiki, I first had _MPDF_PATH in mpdf.php set to:

if (!defined('_MPDF_PATH')) define('_MPDF_PATH','mpdf/');

After I changed it to the absolute path, everything worked. The absolute path looks like this:

if (!defined('_MPDF_PATH')) 
define('_MPDF_PATH','/home/example.com/htdocs/ci/application/libraries/mpdf/');



回答2:


I had the same problem. I've found my problem was the font. It was corrupted I've downloaded the font from internet and I've replaced it in the ttfonts folder. Everything worked!




回答3:


Instead of defining _MPDF_PATH like this...

if (!defined('_MPDF_PATH')) define('_MPDF_PATH','mpdf/');

Change path according to this one... this will work without any error if you placed mdpf directory in your libraries dir

if (!defined('_MPDF_PATH')) define('_MPDF_PATH', APPPATH . 'libraries/mpdf/');




回答4:


Got same result after uploading library files (auto) converted to lowercase filenames by file manager.



来源:https://stackoverflow.com/questions/8460604/mpdf-cannot-find-ttf-truetype-font-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!