Skip to content

Instantly share code, notes, and snippets.

@pomarec
Created April 18, 2012 15:04
Show Gist options
  • Save pomarec/2414175 to your computer and use it in GitHub Desktop.
Save pomarec/2414175 to your computer and use it in GitHub Desktop.
Takes a pdf in argument and spit all its pages in differents files.
#!/usr/bin/python
# install pyPdf "sudo pip install pyPdf"
from pyPdf import PdfFileWriter, PdfFileReader
import sys
input1 = PdfFileReader(file(sys.argv[1], "rb"))
for i in range(input1.getNumPages()):
output = PdfFileWriter()
output.addPage(input1.getPage(i))
outputStream = file("o" + str(i) + ".pdf", "wb")
output.write(outputStream)
outputStream.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment