xxxxxxxxxx
# Shell
pip install pdfkit
sudo apt-get install wkhtmltopdf
# Python
import pdfkit
pdfkit.from_file('input.html','shaurya.pdf') # .from_url and .from_string also exist
# Source: https://www.geeksforgeeks.org/python-convert-html-pdf/
xxxxxxxxxx
import pdfkit
# Path to the HTML file you want to convert
html_file = 'path/to/your/file.html'
# Path to save the generated PDF
pdf_file = 'path/to/save/output.pdf'
# Convert HTML to PDF
pdfkit.from_file(html_file, pdf_file)