Question

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?

Was it helpful?

Solution

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/');

OTHER TIPS

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!

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/');

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top