Home  >  Article  >  Backend Development  >  PHP MPDF中文乱码的解决方式_php实例

PHP MPDF中文乱码的解决方式_php实例

WBOY
WBOYOriginal
2016-06-07 17:10:401222browse

废话不多说了,直接奔入主题了。

推荐教程:PHP使用MPDF类生成PDF的方法

1.config.php文件,大约67行:

$this->autoLangToFont = true; 

2.使用的时候

注意, +aCJK 这个参数,而不是  c这个参数

$mpdf=new \mPDF('+aCJK','A4','','',32,25,27,25,16,13); 
$mpdf->WriteHTML($content); 
$mpdf->Output(); 

然后就输出中文了

这个针对版本mPDF6.0

ps:mpdf生成中文乱码的解决方法

useAdobeCJK = true;
$mpdf->SetAutoFont(AUTOFONT_ALL);
$mpdf->SetDisplayMode('fullpage');
//$mpdf->watermark_font = 'GB';
//$mpdf->SetWatermarkText('中国水印',0.1);
$url = 'http://www.kuitao8.com/';
$strContent = file_get_contents($url);
//print_r($strContent);die;
$mpdf->showWatermarkText = true;
$mpdf->SetAutoFont();
//$mpdf->SetHTMLHeader( '头部' );
//$mpdf->SetHTMLFooter( '底部' );
$mpdf->WriteHTML($strContent);
$mpdf->Output('ss.pdf');
//$mpdf->Output('tmp.pdf',true);
//$mpdf->Output('tmp.pdf','d');
//$mpdf->Output();
exit;
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn