#!/usr/bin/env python

import sys

from pyPdf import PdfFileWriter, PdfFileReader

infile=sys.argv[1]

inputpdf = PdfFileReader(open(infile, "rb"))

for i in xrange(inputpdf.numPages):
        output = PdfFileWriter()
        output.addPage(inputpdf.getPage(i))
        with open("document-page%s.pdf" % i, "wb") as outputStream:
            output.write(outputStream)
