In python, converting a html file to pdf is very simple. We can use pdfkit library to do it. In this tutorial, we will write an example to show you how to convert.
Install pdfkit library
pip install pdfkit
Install wkhtmlpdf application
You can download it in here.
As win 10 system, you can choose 64 bit to download.
Then we can start to convert a html to pdf
Convert a html to pdf
import pdfkit pdfkit.from_url('https://www.tutorialexamples.com', 'out-test.pdf')
However, if you find OSError: No wkhtmltopdf executable found. you can read this tutorial to fix this error.