我正在尝试在我的电子商务网站中生成订单摘要的 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
我使用烧瓶作为网络框架,这是代码:
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
我在互联网上搜索,但没有任何相关的东西可以解决问题。