Mobile app version of vmapp.org
Login or Join
Margaret771

: Combining Multiple PDF Files with different numbers of pages 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

@Margaret771

Posted in: #Pdf

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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Margaret771

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini998

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme