Search code examples
phppdffpdf

Parentheses appearing as ASCII codes in FPDF?


I'm using FPDF to create documents with certain text elements (as Cells) populated from a MySQL query. One such field is $company.

Whenever the company name contains parentheses (ie 'Acme Fixings (UK) Ltd') the resulting PDF reads

Acme Fixings (UK) Ltd

I've tried using addslashes() to escape the parentheses to no avail. Replacing the variable with a single-quoted string works fine.

I'm using the supplied Arial font.

Any clues?

Thanks, Dan


Solution

  • It seems that for some reason when inputting data into the database, parentheses were deemed hazardous and therefore encoded as HTML entities.

    html_entity_decode reverses this process, resulting in parentheses.

    Note that if you were outputting it to a browser and it "seemed" fine, it's because the browser decodes HTML entities. You should use View Source to see what is actually being output by the server.