wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely “headless” and do not require a display or display service.
wkhtmltopdf 和 wkhtmltoimage是一个开元的命令行工具，用来转换html为pdf和各种图像格式。
brew install Caskroom/cask/wkhtmltopdf
- Download a precompiled binary or build from source
- Create your HTML document that you want to turn into a PDF (or image)
- Run your HTML document through the tool.
- For example, if I really like the treatment Google has done to their logo today and want to capture it forever as a PDF:
wkhtmltopdf http://google.com google.pdf
pdfkit 是 wkhtmltopdf 的Python封装包。
npm install pdfkit
'ascii' codec can't decode byte 0xb4 in position 11: ordinal not in range(128）
with open(src + filename, encoding="utf-8")