Zend_Pdf
在Zend Framework 1.5版本中支持UTF-8。但是,标准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