如何解决wkhtmltopdf :由于网络错误退出代码 1:RemoteHostClosedError
我正在尝试在我的电子商务网站中生成订单摘要的 pdf,但收到以下错误。
OSError: wkhtmltopdf reported an error:
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[=========> ] 16%
[============> ] 20%
[================> ] 27%
[===================> ] 32%
[=====================> ] 36%
[========================> ] 40%
[=========================> ] 42%
[===================================> ] 59%
[=====================================> ] 62%
[========================================> ] 68%
[===========================================> ] 72%
[============================================> ] 74%
[==============================================> ] 77%
[===============================================> ] 79%
[=================================================> ] 82%
[==================================================> ] 84%
[====================================================> ] 87%
[=====================================================> ] 89%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[==============================> ] Page 1 of 2
[============================================================] Page 2 of 2
Done
Exit with code 1 due to network error: RemoteHostClosedError
我使用flask作为网络框架,代码如下:
rendered = render_template("order-summary.html",total_cost=total_cost,name=name,price=price)
config = pdfkit.configuration(wkhtmltopdf=r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe')
pdf = pdfkit.from_string(rendered,False,configuration=config)
response = make_response(pdf)
response.headers['Content-Type'] = 'application/pdf'
response.headers['Content-disposition'] = 'inline; filename=output.pdf'
return response
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。