Linux 配置 wkhtmltopdf

官网地址

wkhtmltopdf :https://wkhtmltopdf.org/

作用:可以把html页面转换成pdf格式

Linux下安装wkhtmltopdf

检查linux服务器版本 在官网根据版本下载

安装

# 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

解压

# 版本:centos8 wkhtmltox-0.12.6-1 版本
rpm -ivh wkhtmltox-0.12.6-1.centos8.x86_64.rpmr 

如果其他版本的deb后缀,需要安装dpkg解压(压缩包后缀不是deb的可跳过)

# 安装到当前wk目录下  这个是其他版本的
dpkg -x wkhtmltox_0.12.6-1.bionic_amd64.deb wk 

把解压后的usr文件覆盖到服务器的usr目录里面 

#查看版本 如果成功输入版本即代表安装成功
wkhtmltopdf -V 

报错error while loading shared libraries: libXrender.so.1需要安装

#报错 error while loading shared libraries: libXrender.so.1 需要安装
apt-get install libXrender*

报错 error while loading shared libraries: libfontconfig.so.1需要安装 

#报错 error while loading shared libraries: libfontconfig.so.1需要安装 
apt-get install libfontconfig* 

 调用

#调用wkhtmltopdf
wkhtmltopdf https://www.baidu.com bd.pdf

中文乱码显示白色方格,在/usr/share/fonts/目录下创建一个chinese文件,把windows里面的simsun.ttf字体文件拉进去即可

  

  

 

posted @ 2024-04-26 18:09  靓仔姓曹  阅读(381)  评论(0编辑  收藏  举报
  
爱,其实很简单,困难的是去接受它。