How to Merge PDF with PDF.co Web API

In this tutorial, we’re going to see how we can merge two PDF files using the PDF merging Web API by PDF.co. We’re having the Java implementation for this and we’re going to see how we can do this call in Java. So the approach is the same regardless of whatever language or framework you’re using.

Step 1: Input Details of Files to be Merged

So first of all, we have the placeholder for the API keys, which we provide here. We have two input files. There are two PDF files of the two pages, so the output should be the two pages. We provided the destination file here and an API endpoint. We’re going to use them if you like a v1 PDF merge. We will provide the name of the output file and we will provide the URLs in the comma-separated format.

PDF Merging API

Step 2: Prepare the Request

Here we prepare the request. We provide the API key in the header. We execute the request and if the request goes well, we pass it to the JSON here. Then we’re going to get the URL of the regenerated file, save it here and download it.

How to Merge PDF APi

We created one function here. So what it does, basically, it prepares the request for downloading. It calls a web client, gets the destination file using the file output stream. I replace the keys here and execute the program. The project is being finished.

Step 3: Check the Output

Now, we will examine the output. So, it has generated the result PDF and we can see it contains the two pages – page one from the first input and page two from the second input.

Merge PDF File

So it’s easy to merge the PDF files using the PDF merging API by PDF.co.

Check this PDF.co video tutorial using PDF.co Web API and follow us on YouTube!

Video Guide

Related Tutorials

See Related Tutorials