mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-30 15:31:10 +00:00
Added PDF page extractor
This commit is contained in:
parent
ecaeea1524
commit
33851d1618
7
scripts/pdf_page_extractor/README.md
Normal file
7
scripts/pdf_page_extractor/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# PDF Page Extractor
|
||||||
|
This is a simple script that lets you extract a single page from a pdf.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Clone the repo
|
||||||
|
download the requirements
|
||||||
|
run python script.py
|
12
scripts/pdf_page_extractor/script.py
Normal file
12
scripts/pdf_page_extractor/script.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user