廢話不多說了,直接奔入主題了。
推薦教程:PHP使用MPDF類生成PDF的方法
1.config.php文件,大約67行:
1
|
$this ->autoLangToFont = true; |
2.使用的時候
注意, +aCJK 這個參數,而不是 c這個參數
1
2
3
|
$mpdf = new \mPDF( '+aCJK' , 'A4' , '' , '' ,32,25,27,25,16,13); $mpdf ->WriteHTML( $content ); $mpdf ->Output(); |
然后就輸出中文了
這個針對版本mPDF6.0
ps:mpdf生成中文亂碼的解決方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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 ; ?> |