I need to render an HTML page and download the pdf through the browser as in the example:
@app.route("/test"):
def gerarPDF():
rend = render_template("comprovante.html",var="Aqui vem uma variavel")
pdf = pdfkit.from_string(rend, 'out.pdf')
resp = make_response(pdf)
resp.headers['Content-Type'] = 'application/pdf'
resp.headers['Content-Disposition'] = 'attachment; filiname=test.pdf'
return resp
but, I just want to render and download by browser I want to use inside a function that use return to render another page follows an example but it doesn't download the pdf in the browser it saves directly in the project folder.
from flask import Flask, render_template, make_response
import pdfkit
appFlask = Flask(__name__)
@appFlask.route('/entrada',methods=["GET","POST"])
def entrada():
rend = render_template("comprovante.html",var="Aqui vem uma variavel")
pdfkit.from_string(rend, 'out.pdf')
return render_template("cadastro.html")