PDF报表中文都是乱码
我用系统内置的“[url=http://192.168.9.11/weberp/reportwriter/admin/ReportCreator.php]报表生成工具”(Report and Form Builder)制作了一张报表,但中文全是乱码。但是导出到CSV的中文显示正常。[/url]系统本身自带的报表,中文显示正常。[url=http://192.168.9.11/weberp/reportwriter/admin/ReportCreator.php]
[/url] 论坛有问题,我已经更新了二次开发版的附件,您可以现在去下载。 没发现:L :L 我也遇到这个问题,有解决的方法吗?
weberp中文打印
文章来自 [url=http://leokan.blogchina.com/blog/6021016.html]http://leokan.blogchina.com/blog/6021016.html[/url][b]关键词[/b]: [url=http://tag.bokee.com/tag/webERP][color=#0000ff]weberp[/color][/url] [url=http://tag.bokee.com/tag/fpdf][color=#0000ff]fpdf[/color][/url]
這段時間在研究weberp,開源系統,php+mysql+apache,支持簡體,繁體,日文,韓文,界面很友好,只是在打印的時候會亂碼,我搞了好久終於找到原因可能是老外寫的吧,把簡體和繁體混為一談了,在這個系統中,打印是由fpdf1.52完成,造成亂碼的文件是class.pdf.php
節遷代碼如下:
define('FPDF_FONTPATH','./fonts/');
include ('fpdf.php');
[color=#0cc0]if ($_SESSION['Language']=='zh_CN'){[/color]
[color=#0cc0]include('FPDF_Chinese.php');[/color]
} elseif ($_SESSION['Language']=='ja_JP'){
include('FPDF_Japanese.php');
}elseif ($_SESSION['Language']=='ko_KR'){
include('FPDF_Korean.php');
} else {
class PDF_Language extends FPDF {
}
}
class Cpdf extends PDF_Language {
function Cpdf($pageSize=array(0,0,612,792)) {
$this->PDF_Language( 'P', 'pt',array($pageSize[2]-$pageSize[0],$pageSize[3]-$pageSize[1]));
$this->setAutoPageBreak(0);
$this->AddPage();
$this->SetLineWidth(1);
$this->cMargin = 0;
// Next three lines should be here for any fonts genarted with 'makefont' utility
[color=#0cc0]if ($_SESSION['Language']=='zh_CN'){[/color]
[color=#0cc0]$this->AddBig5Font();[/color]
}elseif ($_SESSION['Language']=='ja_JP'){
$this->AddSJISFont();
}elseif ($_SESSION['Language']=='ko_KR'){
$this->AddUHCFont();
} else {
$this->AddFont('helvetica');
$this->AddFont('helvetica','I');
$this->AddFont('helvetica','B');
}
}
function selectFont($FontName) {
$type = '';
if(strpos($FontName, 'Oblique')) {
$type = 'I';
}
if(strpos($FontName, 'Bold')) {
$type = 'B';
}
[color=#0cc0]if ($_SESSION['Language']=='zh_CN'){[/color]
[color=#0cc0]$FontName = 'Big5';[/color]
} elseif ($_SESSION['Language']=='ja_JP'){
$FontName = 'SJIS';
} elseif ($_SESSION['Language']=='ko_KR'){
$FontName = 'UHC';
} else {
$FontName ='helvetica';
}
$this->SetFont($FontName, $type);
}
很顯然,當$_SESSION['Language']=='zh_CN'時,應為GB,而不是BIG5,只有當$_SESSION['Language']=='zh_HK'才應該是addbig5font以及$FontName='Big5',更改的代碼如下
define('FPDF_FONTPATH','./fonts/');
include ('fpdf.php');
[color=#0cc0]if (($_SESSION['Language']=='zh_HK') or ($_SESSION['Language']=='zh_CN')){[/color]
[color=#0cc0]include('FPDF_Chinese.php');[/color]
} elseif ($_SESSION['Language']=='ja_JP'){
include('FPDF_Japanese.php');
}elseif ($_SESSION['Language']=='ko_KR'){
include('FPDF_Korean.php');
} else {
class PDF_Language extends FPDF {
}
}
class Cpdf extends PDF_Language {
function Cpdf($pageSize=array(0,0,612,792)) {
$this->PDF_Language( 'P', 'pt',array($pageSize[2]-$pageSize[0],$pageSize[3]-$pageSize[1]));
$this->setAutoPageBreak(0);
$this->AddPage();
$this->SetLineWidth(1);
$this->cMargin = 0;
// Next three lines should be here for any fonts genarted with 'makefont' utility
[color=#0cc0]if ($_SESSION['Language']=='zh_HK'){[/color]
[color=#0cc0]$this->AddBig5Font();[/color]
[color=#0cc0]}elseif ($_SESSION['Language']=='zh_CN'){[/color]
[color=#0cc0]$this->AddGBFont();[/color]
}elseif ($_SESSION['Language']=='ja_JP'){
$this->AddSJISFont();
}elseif ($_SESSION['Language']=='ko_KR'){
$this->AddUHCFont();
} else {
$this->AddFont('helvetica');
$this->AddFont('helvetica','I');
$this->AddFont('helvetica','B');
}
}
function selectFont($FontName) {
$type = '';
if(strpos($FontName, 'Oblique')) {
$type = 'I';
}
if(strpos($FontName, 'Bold')) {
$type = 'B';
}
[color=#0cc0]if ($_SESSION['Language']=='zh_HK'){[/color]
[color=#0cc0]$FontName = 'Big5';[/color]
[color=#0cc0]}elseif ($_SESSION['Language']=='zh_CN'){[/color]
[color=#0cc0]$FontName = 'GB';[/color]
} elseif ($_SESSION['Language']=='ja_JP'){
$FontName = 'SJIS';
} elseif ($_SESSION['Language']=='ko_KR'){
$FontName = 'UHC';
} else {
$FontName ='helvetica';
}
$this->SetFont($FontName, $type);
}
這樣就不會有亂碼了 是的,就是这个原因。
页:
[1]