Skip to content

Instantly share code, notes, and snippets.

@reuf
Last active September 30, 2015 09:03
Show Gist options
  • Save reuf/d9e84f09ece78e0e5871 to your computer and use it in GitHub Desktop.
Save reuf/d9e84f09ece78e0e5871 to your computer and use it in GitHub Desktop.
# Loading the pyPdf Library
from pyPdf import PdfFileWriter, PdfFileReader
import os
# Creating a routine that appends files to the output file
def append_pdf(input,output):
[output.addPage(input.getPage(page_num)) for page_num in range(input.numPages)]
# Creating an object where pdf pages are appended to
output = PdfFileWriter()
all_pdfs = [ f for f in listdir(os.getcwd()) if f.endswith(".pdf") ]
for pdf_file in all_pdfs:
print(pdf_file)
# append_pdf(PdfFileReader(file(pdf_file,"rb")),output)
# output.write(file("SveZajedno.pdf","wb"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment