Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Producing symbols from HTML characters in FPDF

I have a government client that requires the legal 'section symbol' (§) in their documents. When creating the documents in a web page, this symbol is created with § or §.

I can not figure out how to get either of these to work in a pdf document created with FPDF. I have tried the iconv and utf8_decode methods, but neither have worked. Any ideas?

like image 934
seveninstl Avatar asked Jan 03 '12 12:01

seveninstl


2 Answers

You're looking for html_entity_decode().

like image 140
SLaks Avatar answered Nov 04 '22 09:11

SLaks


There is an easier approach to do this:

You can generate a section symbol using FPDF with using ascii code: chr(167).

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

define('SECTION',chr(167));

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

echo SECTION.'1.1';

Will output: §1.1

Note: This will also work for other symbols with chr(ascii), where ascii is the ascii code of the symbol. You can find an overview of ascii codes on this page: http://www.atwebresults.com/ascii-codes.php?type=2

like image 25
Gerard de Visser Avatar answered Nov 04 '22 08:11

Gerard de Visser