Zend Framework PDF oluşturma unicode sorunu

3 Cevap php

Ben Zend Framework PDF kullanarak sorun var

When I create PDF file I need to use UTF-8 as encoding. This is the code I am using to generate simple pdf file. I always get this wrong displayed. Instead of seeing 'Faktúra' in pdf file, it gives me 'Faktú' Instead of seeing 'Dodávateľ:' in pdf file, it gives me 'Dodáva'

$pdf = new Zend_Pdf();    
$pdf->pages[] = ($page1 = $pdf->newPage('A4'));    
$font = Zend_Pdf_Font::fontWithPath('C:\WINDOWS\Fonts\TIMES.TTF');    
$page1->setFont($font, 20);    
$page1->drawText('Faktúra', 40, 803, 'UTF-8');    
$page1->drawText('Dodaváteľ:', $width_left, $height, 'UTF-8');

Yani Windows dizininden yazı tipi yüklemek için çalıştı

$font = Zend_Pdf_Font::fontWithPath('C:\WINDOWS\Fonts\TIMES.TTF');

Ama bana hata veriyor:

Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Insufficient data to read 2 bytes'

It is really driving me crazy and I believe some of you would have little hints for me:) Solving the error would be the best solution...

Teşekkür peşin bir sürü

3 Cevap

UTF-8 olarak php kaynak dosyayı kaydetmek mi?

kullanmayı deneyin utf8_decode()

Örneğin:

$pdf = new Zend_Pdf();    
$pdf->pages[] = ($page1 = $pdf->newPage('A4'));    
$font = Zend_Pdf_Font::fontWithPath('C:\WINDOWS\Fonts\TIMES.TTF');    
$page1->setFont($font, 20);    
$page1->drawText(utf8_decode('Faktúra'), 40, 803, 'UTF-8');    
$page1->drawText(utf8_decode('Dodaváteľ:'), $width_left, $height, 'UTF-8');

Zend pdf işlevselliği henüz çok gelişmiş değil. üzerine http://www.starmind.com biz FPDF dayanmaktadır tcpdf hangi kullanın. hem kullanmakta serbesttirler.