Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with FPDF and Euro symbol

I've spent a couple of days sifting through various methods to encourage FPDF to render the Euro symbol, but none have succeeded. I have:

$currency = iconv("UTF-8", "ISO-8859-1//TRANSLIT", '€');

Which results in:

iconv() [function.iconv]: Detected an incomplete multibyte character in input string

I've tried a variety of encoding types, but to no avail.

like image 405
Wayne Smallman Avatar asked Oct 03 '13 12:10

Wayne Smallman


People also ask

Should euro sign be before or after price?

In Statistics Explained articles the symbol '€' should be used for euro in the text if it is followed by a number. This applies also to graphs and tables. It should be placed before the figure: €30.

What is the use of euro symbol?

The symbol € is based on the Greek letter epsilon (Є), with the first letter in the word “Europe” and with 2 parallel lines signifying stability. The ISO code for the euro is EUR. This is used when referring to euro amounts without using the symbol.


2 Answers

You actually can generate a PDF with euro signs using FPDF with using euro ascii code: chr(128).

It's good practice to make this a constant. At the top of your script, add:

define('EURO',chr(128));

Now you can use EURO in your script to print the euro symbol. For example:

"Costs: ".EURO.100

Will output: Costs: €100

Note: This will also work for other symbols with chr(ascii), where ascii is the ascii code of the symbol.

like image 119
Gerard de Visser Avatar answered Oct 26 '22 19:10

Gerard de Visser


I've searched for ages, and nothing worked - until I used this: utf8_encode(chr(128))

like image 10
Zaph Avatar answered Oct 26 '22 21:10

Zaph