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.
- Send PDF File through Email using pdf-mail module
- Convert Text and Text File to PDF using Python
- Convert PDF to Image using Python
- Convert PDF File Text to Audio Speech using Python
- Convert Docx to Pdf usinf docx2pdf Module in Python
- How to Convert Image to PDF in Python?
- Python | Reading contents of PDF using OCR (Optical Character Recognition)
- Python | Scipy stats.halfgennorm.pdf() method
- Python | Scipy stats.hypsecant.pdf() method
- Exporting PDF Data using Python
- Extract text from PDF File using Python
- Merge PDF stored in Remote server using Python
- PDF Redaction using Python
- Build an Application to extract URL and Metadata from a PDF using Python
- Add Watermark to PDF using PyPDF4 in Python
- Modifying PDF file using Python
- Working with PDF files in Python
- Encrypt and Decrypt PDF using PyPDF2
- Python | Convert an HTML table into excel
- Convert CSV to HTML Table in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.