求html转为pdf中文全是问号解决办法

WBOY
Release: 2016-06-23 13:39:48
Original
1870 people have browsed it


html2fpdf将简单的html转为pdf中文乱码我实在是搞不定了,换成了html2pdf
Vendor('html2pdf.html2pdf');
        $html2pdf = new HTML2PDF('P', 'A4', 'fr', true, 'UTF-8', array(30, 20, 25, 25));
        $html2pdf->parsingCss->fontSet('DejaVuSans');
        $html2pdf->WriteHTML("

出来吧大哥

this is a test");
        $html2pdf->Output("sample.pdf",'I');
        echo "PDF file is generated successfully!";
结果出来中文汉字全是问号  
 各位大神,该怎么解决啊 实在没法子了  求大神帮帮忙吧 我实在是没辙了


回复讨论(解决方案)

你的 HTML2PDF 是什么版本的?
Vendor('html2pdf.html2pdf'); 用的是什么框架,连插件都不替你修正好,这个框架有何用?

具体版本我没看懂   应该是这两行中的
 define('__CLASS_HTML2PDF__', '4.03');
   define('HTML2PDF_USED_TCPDF_VERSION', '5.0.002');
用的ThinkPHP框架

你的 HTML2PDF 是什么版本的?
Vendor('html2pdf.html2pdf'); 用的是什么框架,连插件都不替你修正好,这个框架有何用?

这是因为你没有 DejaVuSans 这个字体,另外写法也有点问题
你可以参考一下他提供的样例文件 examples/utf8.php
并将 style="font-family: freeserif">
改为 style="font-family: STSongStdLight"

至于如何使用其他字体,网上的介绍很多

非常感谢  ,我才参加工作两个月 , 基础实在太差了 
 真心感谢您的指导

source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!