PdfKit不适用于我的烧瓶应用程序

问题描述 投票:-1回答:1

你好,我正在使用烧瓶,我想使用pdfkit库以pdf格式下载最近的发票,但遇到很多我无法理解的错误。请检查代码并提供帮助。在此先感谢

def download_invoice():
    if "user" in session and session["user_type"] == "user":
        data = Invoices.get_recent_invoice()
        template = render_template("download_recent_invoice.html", data=data)
        path_wkhtmltopdf = params["path_to_wkhtmltopdf"]
        config_path = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
        invoice_pdf = pdfkit.from_string(template, app.config["DOWNLOAD_INVOICE_PATH"] + str(data.sno) +
                                         str(data.buyer) + ".pdf", configuration=config_path)

        response = make_response(invoice_pdf)
        return response
    else:
        return redirect(url_for("login"))
python flask pdfkit
1个回答
0
投票

好吧,我只是将response = make_response(invoice_pdf)替换为response = Response(invoice_pdf)

它以某种方式工作但未显示pdf输出

© www.soinside.com 2019 - 2024. All rights reserved.