Zend PDF charset - 克罗地亚人物不受支持 - 尝试了一切请帮助

时间:2012-03-15 12:28:25

标签: zend-framework pdf character-encoding

这是我创建PDF文档的代码我看不到čćžšđ我尝试导入.TTF文件但是无法正确导入和使用ttf请帮助     $ pdf = new Zend_Pdf();

// Add new page to the document
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page; 

// Draw something on a page
// Set font
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER), 20); 

///tried to import TTF not working
//$goodDogCoolFont = Zend_Pdf_Font::fontWithPath('dokumenti/cro.TTF');
//$page->setFont($goodDogCoolFont, 36);

// Draw text
#
$page->setFillColor(Zend_Pdf_Color_Html::color('#990000'));
$page->drawText('Račćšđžčun za apartman AID '.$this->ukupnacjena[1]['AID'] , 10, 800, 'Windows-1250');// UTF-8 Also doesnt work

pdfData = $pdf->render(); 

$filename = $this->ukupnacjena[1]['OD-DO'];

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'.pdf"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
echo $pdfData;

2 个答案:

答案 0 :(得分:8)

我遇到了与德语字符类似的问题,并通过用等效的HTML代码替换这些字符[我的情况下的UMLAUTS]找到了解决方案:

$str='German chars ü ä ö';
$str = html_entity_decode($str, ENT_COMPAT, "UTF-8");
$page->drawText($str, 115, 524,"UTF-8");

将打印

German chars ü ä ö

可以帮助你......

答案 1 :(得分:0)

我可以在这篇文章中看到类似的问题。这实际上是一个进口问题。 Unicode characters not showing in Zend_Pdf?