In this tutorial, we’re going to see how we can merge two PDF files using the PDF merging 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 the language or framework you’re using.

PDF Merging API

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.

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 the 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.

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.

 

GET YOUR API KEY Zapier plugin  Explore API Docs

 

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

PDF.co video tutorial

 

PDF.co REST Web API tutorials

Related Pages: