How to generate pdf files _with_ utf-8 multibyte characters using Zend Framework

I have a little problem with the Zend Framework Zend_Pdf. Multibyte characters are deleted from created PDF files. For example. when I write aąbcčdeę, it becomes abcd with Lithuanian letters deprived.

I am not sure if this is especially the problem of Zend_Pdf or php in general.

The source code is encoded in utf-8, as well as the php source file that does the job.

Thank you in advance for your help;)

PS I am running Zend Framework v. 1.6, and I use the font FONT_TIMES_BOLD. FONT_TIMES_ROMAN is working

+5
source share
4 answers

Zend_Pdf UTF-8 1.5 Zend Framework. PDF- Latin1. , Zend_Pdf_Font::FONT_TIMES_BOLD "" . , TTF, .

Mac OS X, , PDF- .

$pdfDoc = new Zend_Pdf();
$pdfPage = $pdfDoc->newPage(Zend_Pdf_Page::SIZE_LETTER);

// load TTF font from Mac system library
$font = Zend_Pdf_Font::fontWithPath('/Library/Fonts/Times New Roman Bold.ttf');
$pdfPage->setFont($font, 36);

$unicodeString = 'aąbcčdeę';
$pdfPage->drawText($unicodeString, 72, 720, 'UTF-8');

$pdfDoc->pages[] = $pdfPage;
$pdfDoc->save('utf8.pdf');

. : http://framework.zend.com/issues/browse/ZF-3649

+10

, Zend_Pdf UTF-8 1.5 - Zend Framework ?

- ? ?

+1

Have you made sure that you set the character encoding as an example from the manual?

// Draw the string on the page
$pdfPage->drawText($unicodeString, 72, 720, 'UTF-8');

If you are trying to use a bold font , can you try one of the other bold fonts?

Zend_Pdf_Font::FONT_COURIER_BOLD
Zend_Pdf_Font::FONT_TIMES_BOLD
Zend_Pdf_Font::FONT_HELVETICA_BOLD
+1
source

ZF v. 1.6, TIMES_BOLD (as I understand it, the only way to make the text bold?)

0
source

All Articles