Skip to content

Commit 33851d1

Browse files
committed
Added PDF page extractor
1 parent ecaeea1 commit 33851d1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# PDF Page Extractor
2+
This is a simple script that lets you extract a single page from a pdf.
3+
4+
Usage
5+
Clone the repo
6+
download the requirements
7+
run python script.py
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import PyPDF2
2+
file = input("Name of your pdf file you want to extract a page from: ")
3+
pdfFileObj = open(file + '.pdf', 'rb')
4+
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
5+
pgnumber = input("Which page would you like to extract?: ")
6+
pageObj = pdfReader.getPage(int(pgnumber) - 1)
7+
pdfWriter = PyPDF2.PdfFileWriter()
8+
pdfWriter.addPage(pageObj)
9+
outputfile = input("Name new pdf file: ")
10+
pdfOutputFile = open(outputfile + '.pdf', 'wb')
11+
pdfWriter.write(pdfOutputFile)
12+
pdfOutputFile.close()

0 commit comments

Comments
 (0)