下载安装 wkhtmltopdf
<https://wkhtmltopdf.org/downloads.html> 服务器 x86-64
服务器安装
rpm -ivh wkhtmltox-0.12.5-1.centos7.x86_64.rpm
安装过程报错:
error: Failed dependencies: fontconfig is needed by wkhtmltox-1:0.12.5-1.centos7.x86_64 libXrender is needed by wkhtmltox-1:0.12.5-1.centos7.x86_64 xorg-x11-fonts-75dpi is needed by wkhtmltox-1:0.12.5-1.centos7.x86_64 xorg-x11-fonts-Type1 is needed by wkhtmltox-1:0.12.5-1.centos7.x86_64
处理方法:
yum install fontconfig freetype libpng libjpeg libX11 lifonbXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
再次执行安装命令,安装成功:
# rpm -ivh wkhtmltox-0.12.5-1.centos7.x86_64.rpm
# wkhtmltopdf -V
# wkhtmltopdf --enable-forms https://www.baidu.com baidu.pdf
3、composer 安装 laravel-snappy组件
composer require barryvdh/laravel-snappy
导出的pdf出现中文乱码,需要给服务器(centos7)安装中文字体:
参考:<https://www.linuxidc.com/Linux/2016-09/135548.htm>
原文:https://juejin.cn/post/7096759068206825502