How to use special characters in FPDF

FPDF is a nice little library for php that allows you to create PDFs on the fly. It’s great for all sorts of document, among them invoices. Until you try to use say a pound (£) or euro (€) sign. Basically the library itself does not support utf-8, so the moment you need to insert anything extra into your document a conversion needs to be done.

To save you some searching and a massive panic attack here is the easy way to do it:

iconv("UTF-8", "ISO-8859-1", "£");

You could also use the same command to do the whole text rather than just the pound sign itself. Example below:

You can use the iconv function at any point, however probably the easiest solution is to put it inside functions of the class you use to extend FPDF:

class myPdf extends FPDF { [...] public function showMoney($money){ $this->cell(10,10,**iconv("UTF-8", "ISO-8859-1", "£").** $money,0); } }