Search code examples
phpfpdffont-awesome

Is possible to embed fontawesome font in fpdf?


I'd like to use fontawesome in pdf. I generate my pdf using php library fpdf and font embedding. However I cannot make it works.

I use this tool to generate afm file: http://fpdf.fruit-lab.de/

But when I try to use fontawesome I always get white square instead of icons.

I use this syntax to add icon:

MultiCell(0,8,"\uF000 ",0,'C')

enter image description here


Solution

  • I cannot answer for fpdf since I have never used it. However, I do use mPDF and there I use fontawesome regularly - no issues at all. The only thing I have to ensure is that the content I output to the PDF document (mPDF takes this in the form of HTML markup) hast to be UTF8 encoded.

    mPDF is very good so if you are at an early stage of your project you might just consider switching to it. Otherwise, it is worth exploring whether you too are not running into a UTF8 encoding issue.