Skip to content

Instantly share code, notes, and snippets.

@chocobn69
Created August 10, 2015 07:52
Show Gist options
  • Save chocobn69/6defca0abf1892e6bdda to your computer and use it in GitHub Desktop.
Save chocobn69/6defca0abf1892e6bdda to your computer and use it in GitHub Desktop.
from PyPDF2 import PdfFileWriter,PdfFileReader
pdf1=PdfFileReader(open("C:/Users/andy/Documents/temp.pdf"))
pdf2=PdfFileReader(open("C:/Users/andy/Documents/temp.pdf"))
writer = PdfFileWriter()
# add the page to itself
for i in range(0,pdf1.getNumPages()):
writer.addPage(pdf1.getPage(i))
for i in range(0,pdf2.getNumPages()):
writer.addPage(pdf2.getPage(i))
# write to file
with file("destination.pdf", "wb") as outfp:
writer.write(outfp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment