weasyprint does not load flask images

Viewed 195

Hello friends I have a code to generate pdf with weasyprint from flask and it turns out that it works and generates the pdf but the html that I am rendering has two images and it does not render them for me I have the following code:

from weasyprint import HTML
image = "/static/images/logo-ori.png"
name = "Pepito perez"
print_html = render_template('cert/certificado.html', img=image)

Up to this point the image renders sim problem but when I go to convert it to pdf it no longer renders it

cert = os.path.join(url_direct, "certificado.pdf")
pdf = HTML(string=print_html)
pdf.write_pdf(cert)

The pdf is stored on the server which is what I want to do and with flask I redirect to start I hope they can help me I was reviewing how to use flask-weasyprint but I cannot store the pdf on the server I hope they can help me with either of the two. Thank you in advance Thank you

0 Answers
Related