Skip to content

Commit fe9b804

Browse files
committed
add html to pdf script
1 parent 7632b46 commit fe9b804

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

HTML_TO_PDF_Converter/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1.Intall Python3 on your system.
2+
2.Install pip.
3+
3.Install the requirements.txt.
4+
4.Install wkhtmltopdf ---> https://wkhtmltopdf.org/downloads.html depedning on your operating system.
5+
6+
On setting up the above run the code as : python3 htmltopdf.py, it will prompt for the URL and the pdf output file. The converted file will be stored in the HTML_TO_PDF_Convertor.

HTML_TO_PDF_Converter/htmtopdf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Install python3
2+
#Install pip
3+
#Install pdfkit --> pip install pdfkit
4+
#Install wkhtmltopdf ---> https://wkhtmltopdf.org/downloads.html depedning on your operating system.
5+
6+
import pdfkit
7+
import os
8+
9+
fr_url = input('Enter the url the html of which will be converted to pdf : ')
10+
to_pdf = input('Enter the output of the file without pdf extension :')
11+
12+
try:
13+
pdfkit.from_url(fr_url,to_pdf+'.pdf')
14+
except:
15+
print("Some error occured while converting to pdf. Please check entered url and output file format")
16+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pdfkit==0.6.1

0 commit comments

Comments
 (0)