Python Convert Html to PDF
Convert HTML/webpage to PDF
There are many websites that do not allow to download the content in form of pdf, they either ask to buy their premium version or don’t have such download service in form of pdf.
Conversion in 3 Steps from Webpage/HTML to PDF
Step1: Download library pdfkit
$ pip install pdfkit
Step2: Download wkhtmltopdf
sudo apt-get install wkhtmltopdf
(a)Download link: WKHTMLTOPDF
(b)Set: PATH variable set binary folder in Environment variables.
Step3: Code in Python to Download:
(i) Already Saved HTML page
(ii) Convert by website URL
(iii) Store text in PDF
Congratulations: Your pdf file would be created and saved in the same directory where python file exists.
Miscellaneous Knowledge Content:
1. You can pass a list with multiple URLs or files:
2. Save content in a variable
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course