Linux 配置 wkhtmltopdf
发表于:2024-07-27 17:26:58浏览:643次
官网地址:https://wkhtmltopdf.org/
作用:可以把html页面转换成pdf格式
1. 安装
# liunx下载 版本:centos8 wkhtmltox-0.12.6-1 版本
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm
2. 解压
# 版本:centos8 wkhtmltox-0.12.6-1 版本
rpm -ivh wkhtmltox-0.12.6-1.centos8.x86_64.rpm
3. 如果第二步出现提示jar包 、安装环境缺失的、再执行以下的安装命令
yum -y install fontconfig libX11 libXext libXrender xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 libjpeg*
4. 查看是否安装成功
# 查看版本 如果成功输入版本即代表安装成功
wkhtmltopdf -V
5. 常见问题
1.报错error while loading shared libraries: libXrender.so.1需要安装
#报错 error while loading shared libraries: libXrender.so.1 需要安装
apt-get install libXrender*
2.报错 error while loading shared libraries: libfontconfig.so.1需要安装
#报错 error while loading shared libraries: libfontconfig.so.1需要安装
apt-get install libfontconfig*
3.中文乱码显示白色方格
在/usr/share/fonts/目录下创建一个chinese文件夹
赋值权限chmod -R 755 /usr/share/fonts/chinese
把windows(C:\Windows\Fonts)里面的simsun.ttf字体文件拉进去即可
4.刷新Liunx字体缓存
mkfontdir
mkfontscale
fc-cache –fv
fc-list :lang=ZH

