问题:python3 如何转换html到pdf
描述:
我的电脑是windows764位,python3.4
我想用python 转换html到pdf.
我尝试了html2pdf,貌似它只支持Python2
我又尝试了wkhtmltox-0.12.2.2_msvc2013-win64和pdfkit,并用下面的例子测试。
import pdfkit pdfkit.from_url('http://google.com', 'out.pdf')
报错信息
Traceback (most recent call last): File "E:\Python34\lib\site-packages\pdfkit\configuration.py", line 21, in __init__ with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b'' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> pdfkit.from_url('http://google.com', 'out.pdf') File "E:\Python34\lib\site-packages\pdfkit\api.py", line 22, in from_url c File "E:\Python34\lib\site-packages\pdfkit\pdfkit.py", line 38, in __init__ self.configuration = (Configuration() if configuration is None File "E:\Python34\lib\site-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
请大神们告诉我,该怎么做呢?
解决方案1:
直接使用里边的wkhtmltopdf即可
wkhtmltopdf http://google.com a.pdf
解决方案2:
把可执行文件的路径加入到环境变量里
以上介绍了“python3 如何转换html到pdf”的问题解答,希望对有需要的网友有所帮助。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“Python3转换html到pdf的不同解决方案”评论...
更新动态
2025年04月28日
2025年04月28日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]