from pyPdf import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
input1 = PdfFileReader(file("1.pdf", "rb"))
for i in range(input1.getNumPages()):
output.addPage(input1.getPage(1))
outputStream = file("document-output.pdf", "wb")
output.write(outputStream)
outputStream.close()
Example pdf file can be found here (it's a paper named Sequential hashing: A flexible approach for unveiling significant patterns in high speed networks).
I'm no longer maintaining pyPdf, but the project has been forked as pyPdf2 and is being maintained under that new name. (https://github.com/knowah/PyPDF2/)
Example code:
Example pdf file can be found here (it's a paper named Sequential hashing: A flexible approach for unveiling significant patterns in high speed networks).