首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >wkhtmltopdf配置路径

wkhtmltopdf配置路径
EN

Stack Overflow用户
提问于 2020-01-13 17:37:35
回答 1查看 3.1K关注 0票数 1

所以我想设置一个脚本,它将接受一个网页,并将其转换为pdf。我的wkhtmltopdf配置似乎有问题。这是我不知道该怎么做的部分:“并将带有wkhtmltopdf二进制文件的文件夹添加到路径中。”我希望在这个脚本上能得到一些帮助。谢谢!

这是我的代码:

代码语言:javascript
运行
复制
import pdfkit
pdfkit.from_url('https://grapaes.com/282-newsletter/', 'news282.pdf')
print("I did it!")

这是我的错误消息:

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "C:/Users/Gittel/PycharmProjects/untitled1/website as pdf", line 2, in <module>
    pdfkit.from_url('https://grapaes.com/282-newsletter/', 'news282.pdf')
  File "C:\Users\Gittel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pdfkit\api.py", line 23, in from_url
    r = PDFKit(url, 'url', options=options, toc=toc, cover=cover,
  File "C:\Users\Gittel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pdfkit\pdfkit.py", line 42, in __init__
    self.configuration = (Configuration() if configuration is None
  File "C:\Users\Gittel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pdfkit\configuration.py", line 24, in __init__
    raise IOError('No wkhtmltopdf executable found: "%s"\n'
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

Process finished with exit code 1
EN

Stack Overflow用户

发布于 2021-08-20 19:44:32

代码语言:javascript
运行
复制
import pdfkit
from pdfkit.api import configuration

wkhtml_path = pdfkit.configuration(wkhtmltopdf = "C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe")  #by using configuration you can add path value.

pdfkit.from_url('https://stackoverflow.com/questions/33705368/unable-to-find-wkhtmltopdf-on-this-system-the-report-will-be-shown-in-html', 'C:/Users/Admin/Desktop/Trial1.pdf', configuration = wkhtml_path)
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59713875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档