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 (将#修改为@)