Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python weasyprint不加载烧瓶图像_Python_Python 3.x_Pdf_Flask - Fatal编程技术网

Python weasyprint不加载烧瓶图像

Python weasyprint不加载烧瓶图像,python,python-3.x,pdf,flask,Python,Python 3.x,Pdf,Flask,您好,朋友们,我有一个从flask使用weasyprint生成pdf的代码,它可以工作并生成pdf,但我正在渲染的html有两个图像,它不能为我渲染它们。我有以下代码: from weasyprint import HTML image = "/static/images/logo-ori.png" name = "Pepito perez" print_html = render_template('cert/certificado.html', img

您好,朋友们,我有一个从flask使用weasyprint生成pdf的代码,它可以工作并生成pdf,但我正在渲染的html有两个图像,它不能为我渲染它们。我有以下代码:

from weasyprint import HTML
image = "/static/images/logo-ori.png"
name = "Pepito perez"
print_html = render_template('cert/certificado.html', img=image)
到目前为止,图像呈现sim问题,但当我将其转换为pdf时,它不再呈现

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

pdf存储在服务器上,这正是我想要做的,使用flask我重定向到开始,我希望他们能帮助我我正在复习如何使用flask weasyprint,但我无法将pdf存储在服务器上,我希望他们能帮助我使用这两种方法中的任何一种。提前感谢您感谢您的朋友,他们可以使用Pythony提供的相同解决方案帮助您解决错误,以下链接是所有信息: