Created
December 20, 2020 20:35
-
-
Save dustinknopoff/a86ee89775d74e3a0ee0e72e179ef967 to your computer and use it in GitHub Desktop.
Split pdf into separate pages
This file contains hidden or 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
# Answer from https://stackoverflow.com/a/490203 | |
from PyPDF2 import PdfFileWriter, PdfFileReader | |
inputpdf = PdfFileReader(open("document.pdf", "rb")) | |
for i in range(inputpdf.numPages): | |
output = PdfFileWriter() | |
output.addPage(inputpdf.getPage(i)) | |
with open("document-page%s.pdf" % i, "wb") as outputStream: | |
output.write(outputStream) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment