http://html2pdf.fr/en/default (类库的主页,点最上方的github, 可以去下载类库)
下载好后,就是在yii中使用它。由于它的文件结构不符合yii的自动加载方式,所以我们手动加载。在yii目录结构中,修改backend/web/index.php, 加入$vendordir = dirname(dirname(__dir__)) . '/vendor';
$application = new yii\web\application($config);
yii::$classmap['html2pdf'] = $vendordir . '/html2pdf/html2pdf.class.php'; // 在启动yii的之前加上这个类
$application->run();
用法:在yii的某个controller中,
use html2pdf;
....
try
{
$html2pdf = new html2pdf('p','a4','en', true, 'utf-8', array(15, 5, 15, 5));
$html2pdf->setdefaultfont('javiergb'); // 这是一个中文字体库,在(weberp/includes/tcpdf/fonts/目录中)weberp需要手动下载,http://sourceforge.net/projects/web-erp/
$html2pdf->pdf->setdisplaymode('fullpage');
$html2pdf->writehtml($pdfcontent);
$filename = $orderid . '.pdf';
$html2pdf->output($filename);
}
catch(html2pdf_exception $e) {
echo $e;
exit;
}
最后上一个pdf转html的网站 http://www.htmlpublish.com/convert-pdf-to-html/
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了yii集成html2pdf,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
