Python转换html为PDF

 Sun 07 June 2020   In 爬虫   :)

wkhtmltopdf

Convert HTML to PDF using Webkit (QtWebKit) using the QT Webkit rendering engine include: wkhtmltopdf & wkhtmltoimage pdfkit是基于wkhtmltopdf的python封装

script

wkhtmltopdf xxxx yyy.pdf

python

lib_path = r'wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=lib_path)
detail = pdfkit.from_url(url, "yyy.pdf", configuration=config)

reference

wkhtmltopdf-doc