Home > Backend Development > PHP Tutorial > PHP MPDF中文乱码的解决方式_PHP

PHP MPDF中文乱码的解决方式_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-28 13:12:57
Original
1382 people have browsed it

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

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

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

$this->autoLangToFont = true; 
Copy after login

2.使用的时候

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

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

然后就输出中文了

这个针对版本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;
?>
Copy after login

Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template