Zend_Pdf currency symbol not show on Linux Server

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Pdf currency symbol not show on Linux Server

florin.serbu
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hello!
My name is Florin, I am junior php developer and I have the following issue with Zend_Pdf :
I builded a PDF generated page on my Windows server (php vers: 5.2.13) using Zend.

I used diferent fonts and the currency symbol was displayed correct.

When I've deployed my Zend Application on a Linux server (php vers: 5.3.2-2) the currency symbols didn't show up.

I've used the same Zend Library version on both servers; I've tried with 'utf-8' parameter on drawText function, with diferents fonts.

Nothing Changed.

Coud you give me a small sudggestion on this?
I think is a server related issue, but I can't figure how to solve it.

Thanks in advance !
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

florin.serbu
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

David Muir
In reply to this post by florin.serbu
Which currency?

David
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

florin.serbu
This post has NOT been accepted by the mailing list yet.
Euro currency; With the USD currency it works just fine.

Thanks,
Florin.
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

David Muir
Does the € symbol show up correctly if you simply do <?php echo '€';?> ?
My guess is probably that the source is encoded as either Windows-1252 or ISO-8859-1, and when you're generating the PDF, it's incorrectly treating it as if it were UTF-8 encoded.

Can you post some sample code?

David
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

Jurian Sluiman-4
We had the same problem with euro signs in DomPdf. We replaced all symbols
with the XML notation and now they all work.

$currency->setFormat(array('symbol' => '&#0128;'))

Regards, Jurian
--
Jurian Sluiman
Soflomo - http://soflomo.com
On Monday 08 Nov 2010 15:03:56 David Muir wrote:
> Does the € symbol show up correctly if you simply do <?php echo '€';?> ?
> My guess is probably that the source is encoded as either Windows-1252 or
> ISO-8859-1, and when you're generating the PDF, it's incorrectly treating
> it as if it were UTF-8 encoded.
>
> Can you post some sample code?
>
> David
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

florin.serbu
In reply to this post by David Muir

David Muir wrote
Does the € symbol show up correctly if you simply do <?php echo '€';?> ?
My guess is probably that the source is encoded as either Windows-1252 or ISO-8859-1, and when you're generating the PDF, it's incorrectly treating it as if it were UTF-8 encoded.

Can you post some sample code?

David
Yes, the symbol shows up if I write: var_dump($symbol);exit();

Here you have the sample code:
$pdf = new Zend_Pdf ();
		
		$style = new Zend_Pdf_Style ();
		$style->setFillColor ( new Zend_Pdf_Color_Rgb ( 0, 0, 0 ) );
		$style->setLineColor ( new Zend_Pdf_Color_GrayScale ( 0 ) );
		$style->setLineWidth ( 1 );
		//if I dump here, will show the symbol in a blank pahe
                //var_dump($c); exit();
                $page = new Zend_Pdf_Page ( Zend_Pdf_Page::SIZE_A4 );
		$page->setStyle ( $style );
                $page->setFont ( Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10 );
		$pointer = array ("x" => 70, "y" => 800 );	
                $c = '€' ;

		$page->drawText ('Currency:'.' '.$c, $pointer ['x'] , $pointer ['y']);

		$pdf->pages[] = $page; 	
                $pdf->save ('MyPdf.pdf');
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

florin.serbu
This post has NOT been accepted by the mailing list yet.
In reply to this post by Jurian Sluiman-4
Jurian Sluiman wrote
We had the same problem with euro signs in DomPdf. We replaced all symbols
with the XML notation and now they all work.

$currency->setFormat(array('symbol' => '€'))
and $currency is an object of what class ?
can you write a bit more code ?

Thank you for your answers !
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

florin.serbu
In reply to this post by Jurian Sluiman-4
Jurian Sluiman wrote
We had the same problem with euro signs in DomPdf. We replaced all symbols
with the XML notation and now they all work.

$currency->setFormat(array('symbol' => '€'))
Probably you mean Zend_Currency.
If it's like that, I have tried with your method;

On windows server it is working, when I am outputing $currency->getSymbol();
Still on linux isn't working.
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Pdf currency symbol not show on Linux Server

florin.serbu
I found the solution,


//create Zend_Pdf_Font object
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);

//decode the character with that font and a specified charset eg: UTF-8 
$currency = $font->decodeString( '€','UTF-8');

//output with the same encoding
$page->drawText ( $currency, $x , $y, 'UTF-8');


Thanks for your answers,
Florin.