Linux CentOS7 安装wkhtmltopdf工具

  wkhtmltopdf是一款将html文件转换成pdf格式的优秀的文件内容转换工具。它使用QT作为渲染引擎,目前它的RELEASE版尚不支持flex布局的Html5代码转换。使用flex的嵌套元素将会像没有style修饰的块级元素似的被转换。但是它的测试版使用较新的Qt引擎,可以部分支持flex效果。

安装步骤:

1. 官网下载wkhtmltopdf测试版本0.13.0的rpm包——https://wkhtmltopdf.org/downloads.html

2. 使用yum安装环境,(我用的是webtatic的yum源,依赖包挺全的,之前装的php70w也是通过它)

  (1)yum install icu.x86_64

  (2)yum install xorg-x11-fonts-75dpi.noarch

  (3)yum install xorg-x11-fonts-Type1.noarch

  (4)yum install xorg-x11-server-Xvfb ——(官网里对测试版安装时的提示:Builds for OS X will be made available as soon as support for it is added in the build script, which is an ongoing process. Please note that the above linux builds are not headless, and will require running under xvfb.否则运行‘wkhtmltopdf’转换命令时会报错‘QXcbConnection: Could not connect to display Aborted (core dumped)’)

3. 安装wkhtmltopdf包

4. 使用‘xvfb-run wkhtmltopdf html文件 pdf文件’就可以完成转换。

 

最后flex布局的H5代码转换后,某些特性依然没有转换过来,比如'align-item'、使用flex项目属性的内联元素依然不具备width属性。

转载于:https://www.cnblogs.com/yichi/p/10762264.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值