Merge PDFs, Images, Documents into a Single File in JavaScript using Web API

In this tutorial, we will show you how to merge PDFs, images, and documents into a single file in JavaScript using Web API. Below is the image of our sample source files and the single PDF output.

  1. Source Code
  2. Add API Key
  3. Source Files URL
  4. Run Program
  5. PDF Output
  6. PDF Merger Demo
Sample Source Files And PDF Output
Sample Source Files and PDF Output

Step 1 – Source Code

Let’s copy the PDF Merger source code here and save it as app.js.

Step 2 – Add API Key

In line 21, let’s add our API Key as API_Key variable’s value. You can get your API Key in the dashboard here.

Add API Key

Step 3 – Source Files URL

In line 25, enter the source file links separated by a comma. You can check out the API Docs for the supported file formats. Then, add the destination PDF file name in line 30.

Source Files URL

Step 4 – Run Program

Now, let’s run our program. Type in node app.js in the Terminal. Be sure to set the correct path to your file before you run the command.

Run Program

Step 5 – PDF Output

Great! Let’s check the folder to see the PDF result.

PDF Output

Step 6 – PDF Merger Demo

Here’s the PDF Merger in action.

Merge Any Documents Demo
Merge Any Documents Demo

In this tutorial, you learned how to merge PDFs, images, and documents in JavaScript using Web API. You also learned how to set up the source code to get you started right away.