I have some HTML I am trying to turn into a PDF to make available for download on my Flask app. I am using WeasyPrint and I can get the HTML to render fine in the PDF but I am struggling to make the PNG appear.
Here is my code to create the PDF:
def make_pdf(self):
results = self.compute()
graph = "file:///home/Lynkon/mysite/app/static/fig1.png"
html = render_template('result_pdf.html', form=self, results=results, graph=graph)
pdf = HTML(string=html, base_url='file:///home/Lynkon/mysite/app/static/').write_pdf()
I'm taking some results from a form and displaying it on a HTML template. I would like to display the PDF at the bottom in an img tag like so:
<img src="{{ graph }}">
I've tried several variations of this with no luck. I do not see any error messages, so I must be doing something very stupid. Any suggestions would be greatly appreciated, thank you!