当前位置

网站首页> 程序设计 > 开源项目 > 程序开发 > 浏览文章

Magento 1.x 中文订单打印乱码

作者:小梦 来源: 网络 时间: 2024-08-02 阅读:

magento打印发票会先转换为PDF,但由于内置只有中文字体,所以PDF里的中文会变乱码。

解决方案是追加中文字体,先下载中文字体(推荐微软雅黑ttf),把它放在./lib/Font/msyhbd.ttf

修改以下程序
/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php

protected function _setFontRegular($object, $size = 7){    $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_Re-4.4.1.ttf');    $object->setFont($font, $size);    // 中文字体    $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/Font/msyhbd.ttf');    $object->setFont($font, $size);    return $font;}
protected function _setFontBold($object, $size = 7){    $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf');    $object->setFont($font, $size);    // 中文字体    $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/Font/msyhbd.ttf');    $object->setFont($font, $size);    return $font;}
protected function _setFontItalic($object, $size = 7){    $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_It-2.8.2.ttf');    $object->setFont($font, $size);    // 中文字体    $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/Font/msyhbd.ttf');    $object->setFont($font, $size);    return $font;}

相关阅读

热点阅读

网友最爱