码迷,mamicode.com
首页 > 其他好文 > 详细

Magento打印(配送单、退款单、发票)时PDF中的乱码问题

时间:2015-05-24 21:42:01      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

我使用Magento1.4.2,在其自带的TTF文件不能很好地解析中文字符,TTF文件的位置在网站根目录下的/lib/LinLibertineFont/中。打印的中文字符都是这样的

 

技术分享

 

解决方法:

1.在Windows下复制一个MSYHBD.TTF(微软雅黑)至网站根目录下的/lib/LinLibertineFont/中

2.修改app\code\core\Mage\Sales\Model\Order\Pdf\Abstract.php

 

[php] view plaincopy
 
  1. protected function _setFontRegular($object, $size = 7)  
  2.    {  
  3.        //$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . ‘/lib/LinLibertineFont/LinLibertineC_Re-2.8.0.ttf‘);注释掉这行  
  4.        $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . ‘/lib/LinLibertineFont/MSYHBD.TTF‘);  
  5.        $object->setFont($font, $size);  
  6.        return $font;  
  7.    }  
  8.   
  9.    protected function _setFontBold($object, $size = 7)  
  10.    {  
  11.       // $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . ‘/lib/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf‘);注释掉这行  
  12.       $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . ‘/lib/LinLibertineFont/MSYHBD.TTF‘);  
  13.        $object->setFont($font, $size);  
  14.        return $font;  
  15.    }  
  16.   
  17.    protected function _setFontItalic($object, $size = 7)  
  18.    {  
  19.        //$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . ‘/lib/LinLibertineFont/LinLibertine_It-2.8.2.ttf‘);注释掉这行  
  20.        $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . ‘/lib/LinLibertineFont/MSYHBD.TTF‘);  
  21.        $object->setFont($font, $size);  
  22.        return $font;  
  23.    }  

注:这里主要是讲解解决方法,实际修改请将上述方法写成插件的形式,不要破坏Magento的产品代码。

 

原文:http://blog.csdn.net/liangpei2008/article/details/7574694

Magento打印(配送单、退款单、发票)时PDF中的乱码问题

标签:

原文地址:http://www.cnblogs.com/sunsoftware/p/4526434.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!