1

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?

Regards,

Neal

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

Well i would use some scripting language. Something like:

#!/usr/bin/python
# -*- 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"
    M.merge(0,pdf_file)
    M.merge(0,blank_file)
    M.write("path/to/output")

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, privacy policy and cookie policy

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