Skip to content

Commit 7cc4afc

Browse files
committed
Webpage to pdf
1 parent 7790945 commit 7cc4afc

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Python/webpage-to-pdf/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Webpage to pdf
2+
- - - - - -
3+
## Aim
4+
Aim of the script is to convert a webpage to pdfcrowd
5+
6+
## Requirements
7+
```pip install pdfcrowd```
8+
9+
## Authentication
10+
11+
- Go to ```https://pdfcrowd.com/```
12+
- Login/signup with your email id and username
13+
- Goto Account > Change API KEY
14+
- You can either chose to change the key or use the one given
15+
16+
## To Run
17+
- ```python convert.py```
18+
- Enter your username and KEY
19+
- Webpage will be converted to pdf

Python/webpage-to-pdf/convert.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pdfcrowd
2+
import sys
3+
4+
## ask input URL from user
5+
URL = input("Please enter the URL of webpage you'd like to convert : ")
6+
User = input("Please enter your pdfcrowd API username ")
7+
KEY = input("Please enter your API key ")
8+
try:
9+
# Authenticate API and write result to pdf file in current directory
10+
pdfcrowd.HtmlToPdfClient(User, KEY).convertUrlToFile(URL, 'new.pdf')
11+
12+
except pdfcrowd.Error as why:
13+
# report the error
14+
sys.stderr.write('Pdfcrowd Error: {}\n'.format(why))
15+
# rethrow or handle the exception
16+
raise

0 commit comments

Comments
 (0)