Skip to content

Instantly share code, notes, and snippets.

@luxin88
Created May 12, 2017 02:48
Show Gist options
  • Save luxin88/d803adce8d794a2f15cf7948b87fe081 to your computer and use it in GitHub Desktop.
Save luxin88/d803adce8d794a2f15cf7948b87fe081 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pyPdf import PdfFileReader, PdfFileWriter
out = PdfFileWriter()
for i in range(1, 165):
src_pdf = u"/path/to/pdfs/" + str(i) + u".pdf"
pdf = PdfFileReader(file(src_pdf, 'rb'))
for page in pdf.pages:
out.addPage(page)
ous = file(u"/path/to/dst/file.pdf", 'wb')
out.write(ous)
ous.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment