pyhtmlconv

pyhtmlconv: html converter (image / pdf)


Keywords
html screenshot wkhtmltopdf converter image png jpeg pdf, converter, html, image, pdf, python, screenshot, wkhtmltopdf
License
MIT
Install
pip install pyhtmlconv==1.3

Documentation

pyhtmlconv: html converter (image / pdf)

python html converter (image / pdf)

Installation

Anda perlu menginstall wkhtmltopdf, sebelum menginstall modul ini.

pip install pyhtmlconv

Example

import pyhtmlconv as html
url = "https://google.com"
image = html.convert_to_image(url, "jpeg")
with open("test_image.jpeg", "wb") as fp:
    fp.write(image)

pdf = html.convert_to_pdf(url)
with open("test_file.pdf") as fp:
    fp.write(pdf)

Anda juga dapat mengkonversikan data (image atau pdf) ke bentuk data uri dengan cara menambahkan nilai True pada parameter datauri di fungsi convert_to_image atau convert_to_pdf.