Magento PDF发票,支持中文,以及修改的办法.php
若是让magento的PDF发票支持中文.Magento生成PDF发票.使用的是zend framework的zend_pdf类.
下面是一个简单的,使用zend framework生成pdf文件的用法.[code]<?php
...
// 建立一个新的PDF文档.
$pdf1 = new Zend_Pdf();html
// 加载一个现有的PDF文件.
$pdf2 = Zend_Pdf::load($fileName);app
// 从字符串加载并生成PDF文件.
$pdf3 = Zend_Pdf::parse($pdfString);[/code]okay..很是简单吧..
咱们先来看若是让magento的PDF支持中文.
首先,咱们要明白.Magento为何不支持中文.. 其实zendcart还有joomla都存在这个问题.
是由于这些程序中,使用的文字库并不支持中文.so,咱们只须要替换掉就能够了.字体
此类文件在这里:app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php
找到以下的代码:[code] protected function _setFontRegular($object, $size = 7)
网站
{
$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertineC_Re-2.8.0.ttf');
$object->setFont($font, $size);
return $font;
}code
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);
return $font;
}htm
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);
return $font;rem
}[/code]okay..看到这里你们就知道怎么修改了吧..
只须要把字体的库文件替换一下就ok.文档
.说一下要实现的效果.
由于默认的pdf上,是没有store的名字或者域名的.
客户想在pdf上加上本网站的域名.这样好作区分.字符串
先说个简单的办法.
咱们打开:app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php.而后把这段代码加到[code]$page->drawText(Mage::helper('sales')->__('Website : ') . "你网站的域名", 400, 780, 'UTF-8');[/code][code]$page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');[/code]的下面.
就能够了..
固然,若是以为位置不够好.只须要修改一下坐标$page->drawText(Mage::helper('sales')->__('Website : ') . "你网站的域名", [color=Red]400[/color], [color=Red]780[/color], 'UTF-8');
http://www.zencart-cn.com/zencart-cn-news/article-a-5689.html