Last active
January 11, 2021 06:50
-
-
Save haider11234/cbc0e2c8b0e21302b287586a7ee63153 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#importing libraries | |
from PyPDF2 import PdfFileReader, PdfFileWriter | |
def split(path): | |
pdf = PdfFileReader(path) | |
for page in range(pdf.getNumPages()): | |
pdf_writer = PdfFileWriter() | |
pdf_writer.addPage(pdf.getPage(page)) | |
output = f'page{page}.pdf' | |
with open(output, 'wb') as output_pdf: | |
pdf_writer.write(output_pdf) | |
filename = 'sample.pdf' | |
split(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment