We have a folder with around 4000 PDF files in it.

We are merging these and arranging them 2 up to print on SRA3.

The issue we have hit is that some of the PDF files only contain 3 pages, some contain 4. This throws our setup out when we are trying to arrange them 2 up. We need to combine them, and somehow tell the software to add a 4th blank page into the 3 page documents....

We need to run this in batch...

Any ideas anyone?



  • 1
    Could you not run 2 batches? One to add a 4th page, then one to combine?
    – Scott
    Commented Aug 14, 2014 at 16:01
  • 1
    perhaps you should ask stack overflow
    – joojaa
    Commented Aug 15, 2014 at 4:47

1 Answer 1


Well i would use some scripting language. Something like:

# -*- coding: utf-8 -*-
import PyPDF2

M = PyPDF2.PdfFileMerger()

pdf_file = open("path/toPdf/file", "rb")
pdf = PyPDF2.PdfFileReader(pdf_file)

blank_file = open("path/toABlankPdf/file", "rb")

if pdf.getNumPages() % 2 == 1:
    print "even"

Handles one file. You can then wrap this into a os.walk (tutorial inside) loop to collect all the files. You need a blank one page pdf to refer to for the merging (or it can have any design you like). But yeah this may go over your need. Merger class will also combine as many files as you need. But i leave that for you to do as i have no idea of your file topography

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.