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
- Convert CSV to HTML Table in Python
- Python | Convert an HTML table into excel
- Convert HTML table into CSV file in python
- Python | Convert list to Python array
- Python code to convert SOP to POS
- Python | Convert a set into dictionary
- Python program to convert POS to SOP
- Convert CSV to JSON using Python
- Python | Convert set into a list
- Convert JSON to CSV in Python
- How To Convert Python Dictionary To JSON?
- Convert JSON to dictionary in Python
- Python | Convert tuple to float value
- Python | Ways to convert hex into binary
- Convert binary to string using Python
- Python | Convert String to Tuple
- Python | Convert a list to dictionary
- Python | Convert two lists into a dictionary
- Video to Audio convert using Python
- Python - Convert JSON to string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.