PDF.co makes it easy for you to merge PDFs and other file formats. You can merge PDF files exclusively or merge PDF, DOC, Images, XLS, and ZIP files into a single PDF. Read on to learn how to merge files in Python.
Merge PDF Files
- Add Files to Folder
- Install Requests Module
- Add API Key
- Reference Source Files and Output File
- Run Program
- PDF Merger Demo
- PDF Merger Video Guide
In this demonstration, we will merge 2 PDF files stored in our local machine using the /v1/pdf/merge endpoint. This endpoint is designed to merge PDF files only. If you’d like to merge PDFs and non-PDF files, please check out this demo.
Below is a GIF of the two sample PDF files and the merged PDF output.

Step 1: Add Files to Folder
First, let’s add our sample PDFs to our Python program folder. To follow along, you can download our sample files and Python code here.
Step 2: Install Requests Module
Next, if you haven’t yet, kindly install the requests module. You can do it by running this python -m pip install requests
in your command line.
Step 3: Add API Key
Then, open the Python sample code and go to line 6. Add your PDF.co API Key inside the double-quotes. You can get your API Key in your dashboard here.
Step 4: Reference Source Files and Output File
From lines 12 to 16, add your source PDF files and your desired output PDF file name.
Step 5: Run Program
You can now run your Python program, and you should see the output PDF in your folder.
Step 6: PDF Merger Demo
Here’s the PDF Merger Web API in action.

When you’re working with large files, we highly recommend that you use the async mode. You can find the Python sample code async version here.
Merge PDF, DOC, Images, XLS, and ZIP Files
- Move Files to Folder
- Install Requests Module
- Enter API Key
- Add Source Files and Output File
- Run Program
- PDF Merger Demo
- PDF Merger Video Guide
In this demonstration, we will merge a DOC and a PDF file. We will use the /v1/pdf/merge2 endpoint which supports file formats such as PDF, DOC, XLS, PNG, Zip, and more. If you only want to merge PDF files, please check out this demo.
You can view the source files and the merged output in the image below.

Step 1: Move Files to Folder
To get started, add the sample DOC and PDF to the Python program folder. You can download the sample files and Python code here.
Step 2: Install Requests Module
We will use the requests module in this program. If you haven’t yet, kindly install the requests module by running this python -m pip install requests in the command line.
Step 3: Enter API Key
Now, open the Python sample code and go to line 11. Add your PDF.co API Key inside the double-quotes. You can get your API Key in your dashboard here.
Step 4: Add Source Files and Output File
From lines 17 to 21, add the source files and your desired output PDF file name.
Step 5: Run Program
Run your Python program and you should see the output PDF in your folder.
Step 6: PDF Merger Demo
Here’s the PDF Merger Web API for any documents in action.

In this tutorial, you learned how to merge PDF files. You learned how to merge PDF files and other file formats. You also learned how to use the different PDF Merger Web APIs and what they are designed to do.