问题
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