In this tutorial, we are going to learn how to merge PDF files using #PyPDF2 in Python.

Portable Document Format (PDF) is probably the most widely used file format when it comes to creating document today. By default, most PCs don’t come with PDF files merge/combine feature, and if your #PDF file has sesnitive information, you are running into security risk when using free online tools or 3rd party software. So creating your own Python program to perform PDF files merge task is the safest solution, and the script only takes less than 2 minutes to write.

Before we dive into tutorial, you will need to install PyPDF2 library (pip install PyPDF2).

Buy Me a Coffee? Your support is much appreciated!
PayPal Me:
Venmo: @Jie-Jenn

Source Code:

import os
from PyPDF2 import PdfFileMerger

source_dir = os.getcwd()

merger = PdfFileMerger()

for item in os.listdir(source_dir):
    if item.endswith('pdf'):

merger.write('./Output/Lecture Complete.pdf')