从HTML中使用PDF工具包呈现保存在文件夹中的图像

2024-04-26 09:33:54 发布

您现在位置:Python中文网/ 问答频道 /正文

以下所有内容都是用python编写的

我创建了一些html文件,每个html文件包含一个表、几个div和一个png

html文件中png的路径如下:

<img src = "C:/Users/jtimmins/Documents/FakeLibra/HTMLs/Logos/Test.png" alt = "Picture of a happy monkey" height="25%"/>

但是,当我使用以下代码时:

config = pdfkit.configuration(wkhtmltopdf="C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe")
pdfkit.from_file(f, 'PDFs/{0}.pdf'.format(filename.split('.')[0]), configuration=config)

pdf是用tables和div生成的,但是没有png,我需要做什么才能让png呈现呢


Tags: 文件路径divsrcconfig内容imgpdf