更新时间:2023-02-16 12:52:14
以下应该可以工作而无需修改 windows 环境变量:
The following should work without needing to modify the windows environment variables:
import pdfkit
path_wkhtmltopdf = r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_url("http://google.com", "out.pdf", configuration=config)
当然假设路径是正确的(例如,在我的情况下,它是 r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe').
Assuming the path is correct of course (e.g. in my case it is r'C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe').