EzPDF and Special Characters (Copyright, Trademark and Registered Trademark)

26 Jul

We’ve been kind of struggling here at work with PDF creation.  I switched us to a PDF framework called EzPDF that seems to work fine, except for one simple thing.  Special characters do not show up correctly.

After hours of searching the very little amount of content on the topic, I found a small comment that helped me out:

“Add the following line to functions ezProcessText() in class.ezpdf.php and addText() in class.pdf.php”

In the first row of the function, just add:

$text = mb_convert_encoding($text, “ISO-8859-1”, “UTF-8”);

That solved the issues with the registered and copyright characters.   However, the Trademark symbol was still messed up… Apparently you have to “swap” out one of the 255 characters available with the Trademark…. SOooo..  I decided to swap the upside down question mark ( ¡ ) out for trademarks… For any text blocks that may have a trade mark symbol.. .i need to run some replace code:

$postVar = str_ireplace(‘™’, ‘¡’ , $postVar);
$postVar = str_ireplace(‘™’, ‘¡’ , $postVar);

Also, the first time you select your font in EzPDF… it needs to look something like this:

$insertTradeMark = array(161=>’trademark’);
$pdf->selectFont(‘ezPDF/fonts/Helvetica.afm,  array(‘encoding’=>’WinAnsiEncoding’, ‘differences’=>$insertTradeMark));
161 is the character number for the upside down question mark.  You can see the other numbers and things you can replace them with inside the Helvetica.afm font files that came with EzPDF.

Posted by on July 26, 2010 in Coding


2 responses to “EzPDF and Special Characters (Copyright, Trademark and Registered Trademark)

  1. nalberg

    September 30, 2010 at 4:54 pm

    I have since changed to TCPDF.. which, is similar, yet UTF-8 compliant or something to that extent. Works great.

  2. kalpesh

    May 3, 2013 at 10:03 am

    I want to display arabic language word in PDF reader when export PDF.
    I have one problem with utf-8 in ezpdf reader please give me any sugession or code in php


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: