Created
October 7, 2013 02:46
-
-
Save luanfonceca/6861852 to your computer and use it in GitHub Desktop.
Python code to concatenate PDF files, just keep them ordered by name, like pdf_01, pdf_02, pdf_10...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyPdf import PdfFileWriter, PdfFileReader | |
import os | |
def append_pdf(input, output): | |
[output.addPage(input.getPage(page_num)) \ | |
for page_num in range(input.numPages)] | |
output = PdfFileWriter() | |
for pdf in filter(lambda x: '.pdf' in x, os.listdir('.')): | |
append_pdf(PdfFileReader(file(pdf, "rb")), output) | |
output.write(file("final.pdf", "wb")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment