7

I'm looking for a program that can:

  • add a blank page if the PDF has an odd number of pages (no action if the PDF has an even number of pages). It must be able to process several PDFs at once. (otherwise I can just do it manually)

And if possible (descending priority):

  • works on Windows 7
  • easy to use
  • free

User story: I have to print 30 PDFs. Due to my university printing system, it's time a document is sent to the printer a dialog box pops up to ask to which user ID I want to print the document. In order to avoid getting this dialog box 30 times, I want to combine those 30 PDFs into one PDF. The issue is when I print the combined PDF, sometimes the first page of the initial PDFs is located on the verso of a page, which makes it impossible to staple the printed PDFs one by one.

enter image description here

  • You should probably remove the "easy to use" requirement (like: doesn't crash / has no bugs). That is always an requirement. Also, it is quite subjective. – Martin Thoma Mar 31 '14 at 6:20
  • Why do you look for such a program? Is TeX what you're looking for? – Martin Thoma Mar 31 '14 at 6:20
  • @moose I added the user story in the question. I was simply mentioning easy to use as I fear someone might say "try : Adobe Acrobat scripting scripting, good luck!" :) – Franck Dernoncourt Mar 31 '14 at 14:15
  • This is the same question: stackoverflow.com/q/9820830/562769 – Martin Thoma Mar 31 '14 at 16:48
5

The idea is from this answer on stackoverflow. But as you are a Windows user, I doubt that shell scripts will work for you. So I've implemented a Python version that should also work on Windows.

Preparation

  1. Install Python and make sure you have the pyPDF package.
  2. Create a PDF file with a single blank in /path/to/blank.pdf (I've created blank pdf pages here).
  3. Save this as uniprint.py in any directory of your $PATH. (I'm not a Windows user. This is straight forward under Linux. Please let me know if you get errors / if it works.)
  4. Make uniprint.py executable

Every time you need it

Run uniprint.py a directory that contains only PDF files you want to merge.

Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from argparse import ArgumentParser
from glob import glob
from pyPdf import PdfFileReader, PdfFileWriter

def merge(path, blank_filename, output_filename):
    blank = PdfFileReader(file(blank_filename, "rb"))
    output = PdfFileWriter()

    for pdffile in glob('*.pdf'):
        if pdffile == output_filename:
            continue
        print("Parse '%s'" % pdffile)
        document = PdfFileReader(open(pdffile, 'rb'))
        for i in range(document.getNumPages()):
            output.addPage(document.getPage(i))

        if document.getNumPages() % 2 == 1:
            output.addPage(blank.getPage(0))
            print("Add blank page to '%s' (had %i pages)" % (pdffile, document.getNumPages()))
    print("Start writing '%s'" % output_filename)
    output_stream = file(output_filename, "wb")
    output.write(output_stream)
    output_stream.close()

if __name__ == "__main__":
    parser = ArgumentParser()

    # Add more options if you like
    parser.add_argument("-o", "--output", dest="output_filename", default="merged.pdf",
                      help="write merged PDF to FILE", metavar="FILE")
    parser.add_argument("-b", "--blank", dest="blank_filename", default="blank.pdf",
                      help="path to blank PDF file", metavar="FILE")
    parser.add_argument("-p", "--path", dest="path", default=".",
                      help="path of source PDF files")

    args = parser.parse_args()
    merge(args.path, args.blank_filename, args.output_filename)

Testing

Please make a comment if this works on Windows and Mac.

Please always leave a comment if it doesn't work / it could be improved.

It works on Linux. Joining 3 PDFs to a single 200-page PDF took less then a second.

2

You can use PDFsam:

  • gratis
  • runs on Microsoft Windows, Mac OS X and Linux
  • portable version available (at least on Windows)
  • can add a blank page after each merged document if the document has an odd number of pages

enter image description here

1

You could use PDFtk to merge the documents, and have a one-blank-page pdf file, that you could insert after every document with and odd number of pages. It will be 5 minutes to create a single PDF with 30 documents merged (you can add all the files at once).

As you can see the number of pages of every document, its easy adn fast to do. An example:

enter image description here

Maybe it's not the solution you are looking for, but a workaround.

  • Thanks, is it possible to condition the insertion of the blank page on the parity of the number of pages of the file? I am looking for an automated solution: manually inserting blank pages when needed is a bit tedious if many documents to combine :) – Franck Dernoncourt Mar 31 '14 at 14:34
  • @FranckDernoncourt I know it not an automated system what I propose, but I'll give it a try, you'll see that doing this manually is very fast (you can change the order of the documents just moving them and you have on screen the number of pages, so adding 30 documents and adding the blank-page before every odd-pages one is very fast). – ojovirtual Mar 31 '14 at 14:41
0

There is a program called A PDF Merger.

Does exatcly what you ask:

  1. Add all the files
  2. Go to OptionsPages → add a blank page for odd numbers

It’s free to try with a watermark only on the first page but you can get it free as well.

  • 1
    "but you can get it free as well"?? – user416 Nov 16 '14 at 20:55

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.