html转pdf——Yii2.0 使用Snappy

504 阅读1分钟

1、系统中安装wkhtmltopdf

2、使用composer安装snappy

composer require knplabs/knp-snappy

3、项目中使用Snappy

use Knp\Snappy\Pdf;
$snappy = new Pdf('D:\xampp\wkhtmltopdf\bin\\wkhtmltopdf.exe');
header('Content-Type: application/pdf');
//header('Content-Disposition: attachment; filename="file.pdf"');
print $snappy->getOutput('http://www.163.com');