Merge pull request #258 from rahulkarda/master

Added PDF Page Extractor Script
This commit is contained in:
Advaita Saha 2022-10-09 20:08:55 +05:30 committed by GitHub
commit 91da9562f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,7 @@
# PDF Page Extractor
This is a simple script that lets you extract a single page from a pdf.
## Usage
1. Clone the repo
2. Download the requirements
3. Run python script.py

View File

@ -0,0 +1,12 @@
import PyPDF2
file = input("Name of your pdf file you want to extract a page from: ")
pdfFileObj = open(file + '.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
pgnumber = input("Which page would you like to extract?: ")
pageObj = pdfReader.getPage(int(pgnumber) - 1)
pdfWriter = PyPDF2.PdfFileWriter()
pdfWriter.addPage(pageObj)
outputfile = input("Name new pdf file: ")
pdfOutputFile = open(outputfile + '.pdf', 'wb')
pdfWriter.write(pdfOutputFile)
pdfOutputFile.close()