Python generates PDF data through pdfkit

wkhtmltopdf download address

# -*- coding:utf-8 -*-
import pdfkit


path_wk = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'  # 改成自己安装的位置
config = pdfkit.configuration(wkhtmltopdf=path_wk)
pdfkit.from_string("字符串", 'jmeter_下载文件1.pdf', configuration=config)  # 字符串
# pdfkit.from_url("www.baidu.com", 'jmeter_下载文件2.pdf', configuration=config)    # 网站链接
# pdfkit.from_file("./文件名.html", 'jmeter_下载文件3.pdf', configuration=config)  # 文件名 最好不要用中文

 Remember to install pdfkit pip install pdfkit

 Note that the garbled code in the following figure must be the wrong method of the following three

pdfkit.from_string
pdfkit.from_url
pdfkit.from_file

 

 operation result

 

Guess you like

Origin blog.csdn.net/weixin_43407092/article/details/108150487