拷贝一个中文字体文件例如 simfang.ttf 复制到 tcpdf的 fonts\utils 下,切换到dos窗口,修改目录到这个utils目录下,执行如下命令:
> ttf2ufm -a -f simfang.ttf> php -q makefont.php simfang.ttf simfang.ufm false
utils文件下生成三个文件
simfang.ctg.z simfang.php simfang.z
将这三个文件拷贝到fonts目录下,就可以使用了。
include(html2pdf.class.php'); //引用html2pdf类$html2pdf = new html2pdf('l', 'a4', 'en', true, 'utf-8', array(0, 0, 0, 0));$html2pdf->pdf->setdisplaymode('fullpage');$html2pdf->setdefaultfont('simfang');$html2pdf->writehtml($content, false); //$content为打印到pdf文档的内容$html2pdf->output($filename,'d'); //$filename为下载下来的pdf文档名称