Issues

ZF-5919: PDF Generation unicode issue

Description

Hi all,

I have troubles using Zend Framework's PDF

When I create PDF file I 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::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD); $page1->setFont($font, 20); $page1->drawText('Faktúra', 40, 803, 'UTF-8'); $page1->drawText('Dodávateľ:', $width_left, $height, 'UTF-8'); $pdf->save('test.pdf');

So I tried to load font from Windows directory

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

But it gives me the error:

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:)

Thanks a lot in advance

Comments


<?php

set_include_path(    '/opt/local/lib/php/' . PATH_SEPARATOR . get_include_path() );
require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();

$pdf = new Zend_Pdf();

$pdf->pages[] = ($page1 = $pdf->newPage('A4'));
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
$page1->setFont($font, 20);
$page1->drawText('Faktúra', 40, 803, 'UTF-8');
$page1->drawText('Dodávateľ:', 40, 703, 'UTF-8');

$pdf->save('test.pdf');

worked for me

Faktúra Dodávate:

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.