Python PDF Merger

This post is to show how Python can be used to merge PDF files together. I was using a scanner recently that couldn’t combine multiple pages into a single document, so I had to save each page individually. I found a script at that was a life saver, so I am reproducing it here:

# Loading the pyPdf Library
from pyPdf import PdfFileWriter, PdfFileReader

# Creating a routine that appends files to the output file
def append_pdf(input,output):
 [output.addPage(input.getPage(page_num)) for page_num in range(input.numPages)]

# Creating an object where pdf pages are appended to
output = PdfFileWriter()

# Appending three pdf-pages from three different files

# Writing all the collected pages to a file

Leave a Reply

Your email address will not be published. Required fields are marked *