本人环境配置

wkhtmltopdf: 0.12.3.2
Python: 3.5.2+

问题描述

options = {'encoding': "UTF-8",'custom-header': [('Accept-Encoding', 'gzip')]
}
pdfkit.from_file(['0.html', '1.html'], 'demo.pdf', options=options)

在将多个html文件转换成pdf的时候, 提示:

This version of wkhtmltopdf is build against an unpatched version of QT

发现下面错误有时候pdf已经转换出来 try下 延时下就可以了

except :print '-------------xxxxx-----------'
    time.sleep(2)
Traceback (most recent call last):File "/path/to/jekyll_spider.py", line 148, in <module>main()File "/path/to/jekyll_spider.py", line 144, in mainsave_pdf(html_paths, file_name)File "/path/to/jekyll_spider.py", line 118, in save_pdfpdfkit.from_file(html_path, pdf_path, options=options)File "/usr/local/lib/python3.5/dist-packages/pdfkit/api.py", line 49, in from_filereturn r.to_pdf(output_path)File "/usr/local/lib/python3.5/dist-packages/pdfkit/pdfkit.py", line 156, in to_pdfraise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
Error: This version of wkhtmltopdf is build against an unpatched version of QT, and does not support more then one input document.
Exit with code 1, due to unknown error.

解决方法

下载并使用 0.12.4 版本的 wkhtmltopdf 包 1

$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ sudo cp wkhtmltox/bin/wkhtmlto* /usr/bin/

如果使用PDFkit而没有安装wkhtmltopdf, 则会报如下错误:

Traceback (most recent call last):File "/path/to/jekyll_spider.py", line 148, in <module>main()File "/path/to/jekyll_spider.py", line 144, in mainsave_pdf(html_paths, file_name)File "/path/to/jekyll_spider.py", line 118, in save_pdfpdfkit.from_file(html_path, pdf_path, options=options)File "/usr/local/lib/python3.5/dist-packages/pdfkit/api.py", line 47, in from_fileconfiguration=configuration, cover_first=cover_first)File "/usr/local/lib/python3.5/dist-packages/pdfkit/pdfkit.py", line 42, in __init__self.configuration = (Configuration() if configuration is NoneFile "/usr/local/lib/python3.5/dist-packages/pdfkit/configuration.py", line 27, in __init__'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

Ubuntu可以直接命令行安装wkhtmltopdf:

$ sudo apt-get install wkhtmltopdf

html转pdf错误wkhtmltopdf相关推荐

  1. html转换成pdf工具-wkhtmltopdf、Python生成PDF(pdfkit库)

    文章目录 一.html转换成pdf工具-wkhtmltopdf 1. 什么是wkhtmltopdf 2. 如何使用它? 3. 常见问题 error while loading shared libra ...

  2. HTML 转 PDF 之 wkhtmltopdf

    wkhtmltopdf是一个可以把html转为pdf的插件,有windows.linux等平台的版本,比较简单 官网下载 https://wkhtmltopdf.org/downloads.html  ...

  3. Python使用pdfkit、wkhtmltopdf将html转换为pdf错误记录文档

    1.首先,必须安装一下pdfkit这个模块库,使用命令:pip install pdfkit,安装完成后即可,只需在代码写入一行代码,导入即可: import pdffkit 2.接着,我这边是尝试将 ...

  4. html 转pdf 之wkhtmltopdf

    wkhtmltopdf 是一个开源.简单而有效的命令行 shell 程序,它可以将任何 HTML (网页)转换为 PDF 文档或图像(jpg.png 等). wkhtmltopdf 是用 C++ 编写 ...

  5. html转为pdf工具,wkhtmltopdf html转pdf工具的使用

    wktmltopdf 工具是使用Webkit引擎来将HTML网页转换为PDF文件.其可以将一个URL对应的网页转换为HTML,也可以将存在本地的一个html 文件转换为 pdf 文件.其在应用中有两个 ...

  6. python如何编辑pdf_python3.6 导入并编辑pdf 错误在哪里啊

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 #! python3 # -*- coding: utf-8 -*- """ @Time : 2017/8/17 18:07 ...

  7. vscode markdown 导出PDF错误

    1. 错误提示:"princexml" is required to be installed. 2. 解决:需要安装  prince sudo dpkg -i prince_14 ...

  8. html转换为pdf c#,wkhtmltopdf - 直接在C#中将html代码转换为pdf

    我找到了一个方法. 您可以设置另一个输出正常的html. 并使用该url作为wkhtml2pdf进程的输入值. - - - - - 编辑 public byte[] WKHtmlToPdf(strin ...

  9. JAVA零碎要点011---使用Java操作wkhtmltopdf实现Html转PDF

    JAVA技术交流QQ群:170933152 2.项目中刚开始用的ITEXT把html转换成pdf,但是itext只能转比较规整的html,如果有比如从 editor这种网页编辑的html的话,就有问题 ...

最新文章

  1. Web性能优化实践——应用层性能优化
  2. SAP QM执行事务代码QE23为检验批录入结果,报错-No selected set exists for the inspection point 200 or plant NMDC-
  3. 2021年的“金九银十”你准备好了吗?,腾讯、字节、百度、阿里、快手等一线互联网公司面试真题分享
  4. js函数嵌套调用,无法获取函数返回值
  5. github高级搜索技巧_【建议收藏】百度 quot;隐藏quot; 的高级搜索技巧
  6. HDU 3537 Daizhenyang's Coin
  7. 从“等等”到“秒开”再到“直开”,是什么让闲鱼社区相见恨晚?
  8. 内容可编辑_让PDF像WORD一样自由编辑,好用的PDF编辑工具推荐
  9. Django终端运行报错:ImportError: DLL load failed while importing _sqlite3: 找不到指定的模块。
  10. 所需依赖_注意细节,阿里架构师一文详解SpringDI的四种依赖注入方式
  11. 如何管理kvm虚拟机的时钟源
  12. 查看mysql的默认存储引擎信息_如何查看mysql的默认存储引擎
  13. 洛谷1008 三连击
  14. 计算机二级c语言编译题评分,计算机二级C语言题型和评分标准
  15. 琴岛学院计算机工程系怎么样,青岛理工大学琴岛学院计算机工程系学子荣获全国网络技术挑战赛二等奖...
  16. roboto字体android,Android字体设置及Roboto字体使用方法
  17. 如何在Adobe Illustrator中绘制花园里的小矮人
  18. Windows用virtualBox安装Ubuntu
  19. python实现学生教务系统之自动教师评价
  20. 专升本/四六级/考研英语学习资源汇总

热门文章

  1. python怎么打开turtle_python的turtle库真好玩
  2. Andriod 从源码的角度详解View,ViewGroup的Touch事件的分发机制
  3. 使用oracle客户端与PLSQL连接ORACLE数据库软件安装过程
  4. Android存储-SharedPreferences
  5. 写给自己--70年代的程序员
  6. JVM篇2:[-加载器ClassLoader-]
  7. Linux基本命令之pidof和kill/killall
  8. Android Ap 开发 设计模式第四篇:工厂方法模式
  9. Git命令集十四——抓取命令
  10. Mybatis bug修正