Merge PDF API

Programmatically Combine Multiple PDF Files into a Single Document.

hero banner

Code Examples in Popular Languages

Integrate our Merge PDF API easily into your apps with comprehensive code examples in popular languages to get started quickly.

CURL Request
curl --location 'https://theonlineconverter.com/api/v1/merge-pdf' \
--header 'Content-Type: application/json' \
--header 'x-api-key: enter_your_api_key' \
--form 'file[]=@"/D:/data/Document/pdf/progit.pdf"' \
--form 'file[]=@"/D:/data/Document/pdf/table.pdf"'
JavaScript Fetch
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-api-key", "enter_your_api_key");

const formdata = new FormData();
formdata.append("file[]", fileInput.files[0], "/D:/data/Document/pdf/progit.pdf");
formdata.append("file[]", fileInput.files[0], "/D:/data/Document/pdf/table.pdf");

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: formdata,
  redirect: "follow"
};

fetch("https://theonlineconverter.com/api/v1/merge-pdf", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
Ruby Net::HTTP
import requests
import json

url = "https://theonlineconverter.com/api/v1/merge-pdf"

payload = {}
files=[
  ('file[]',('progit.pdf',open('/D:/data/Document/pdf/progit.pdf','rb'),'application/pdf')),
  ('file[]',('table.pdf',open('/D:/data/Document/pdf/table.pdf','rb'),'application/pdf'))
]
headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'enter_your_api_key'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
Python Requests
import requests
import json

url = "https://theonlineconverter.com/api/v1/merge-pdf"

payload = {}
files=[
  ('file[]',('progit.pdf',open('/D:/data/Document/pdf/progit.pdf','rb'),'application/pdf')),
  ('file[]',('table.pdf',open('/D:/data/Document/pdf/table.pdf','rb'),'application/pdf'))
]
headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'enter_your_api_key'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
PHP Guzzle
<?php
$client = new Client();
$headers = [
  'Content-Type' => 'application/json',
  'x-api-key' => 'enter_your_api_key'
];
$options = [
  'multipart' => [
    [
      'name' => 'file[]',
      'contents' => Utils::tryFopen('/D:/data/Document/pdf/progit.pdf', 'r'),
      'filename' => '/D:/data/Document/pdf/progit.pdf',
      'headers'  => [
        'Content-Type' => '<Content-type header>'
      ]
    ],
    [
      'name' => 'file[]',
      'contents' => Utils::tryFopen('/D:/data/Document/pdf/table.pdf', 'r'),
      'filename' => '/D:/data/Document/pdf/table.pdf',
      'headers'  => [
        'Content-Type' => '<Content-type header>'
      ]
    ]
]];
$request = new Request('POST', 'https://theonlineconverter.com/api/v1/merge-pdf', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
Java HttpURLConnection
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("file[]","/D:/data/Document/pdf/progit.pdf",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("/D:/data/Document/pdf/progit.pdf")))
  .addFormDataPart("file[]","/D:/data/Document/pdf/table.pdf",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("/D:/data/Document/pdf/table.pdf")))
  .build();
Request request = new Request.Builder()
  .url("https://theonlineconverter.com/api/v1/merge-pdf")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("x-api-key", "enter_your_api_key")
  .build();
Response response = client.newCall(request).execute();
Go net/http
package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "os"
  "path/filepath"
  "net/http"
  "io"
)

func main() {

  url := "https://theonlineconverter.com/api/v1/merge-pdf"
  method := "POST"

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  file, errFile1 := os.Open("/D:/data/Document/pdf/progit.pdf")
  defer file.Close()
  part1,
         errFile1 := writer.CreateFormFile("file[]",filepath.Base("/D:/data/Document/pdf/progit.pdf"))
  _, errFile1 = io.Copy(part1, file)
  if errFile1 != nil {
    fmt.Println(errFile1)
    return
  }
  file, errFile2 := os.Open("/D:/data/Document/pdf/table.pdf")
  defer file.Close()
  part2,
         errFile2 := writer.CreateFormFile("file[]",filepath.Base("/D:/data/Document/pdf/table.pdf"))
  _, errFile2 = io.Copy(part2, file)
  if errFile2 != nil {
    fmt.Println(errFile2)
    return
  }
  err := writer.Close()
  if err != nil {
    fmt.Println(err)
    return
  }


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("x-api-key", "enter_your_api_key")

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
C# HttpClient
var options = new RestClientOptions("https://theonlineconverter.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/api/v1/merge-pdf", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-api-key", "enter_your_api_key");
request.AlwaysMultipartFormData = true;
request.AddFile("file[]", "/D:/data/Document/pdf/progit.pdf");
request.AddFile("file[]", "/D:/data/Document/pdf/table.pdf");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

Key Features & Capabilities

Our Merge PDF API is equipped with versatile features for efficient and precise document assembly.

Simple User Interface

Effortless PDF Merging

Combine any number of PDF documents into a single file with a simple API call, streamlining document management and distribution processes.

Simple Data Format

Maintain Document Quality

Our API ensures that the visual integrity, text, and graphics of your original PDFs are perfectly preserved in the newly merged document.

Time

Fast & Reliable Processing

Experience high-speed PDF merging, optimized for performance and reliability, ensuring your combined documents are ready quickly and without corruption.

Secure Data

Large File Support

Designed to reliably handle and merge large, multi-page PDF files without performance degradation or timeouts, suitable for enterprise-level tasks.

Universal Access

Bookmark & Outline Preservation

Intelligently preserves existing bookmarks and document outlines from your source PDFs, consolidating them into the final merged file for easy navigation.

Freedom

Secure Document Handling

Your PDF documents are processed over secure, encrypted connections, and handled with the strictest privacy protocols, guaranteeing data confidentiality.

Frequently Asked Questions

Find answers to common questions about our Merge PDF API to help you integrate and use the service effectively.

Our API is designed to handle multiple input PDFs. The specific number might depend on your subscription plan and the total file size, but typically it supports a significant number of documents.

Absolutely. Our merging process maintains the original quality of all text, images, and formatting from your source PDFs, ensuring a high-fidelity output.

All data transmitted to and from our API is encrypted. We adhere to strict data privacy policies, ensuring your documents are securely processed and are not stored permanently.

Our API is designed to preserve existing bookmarks and hyperlinks, which are consolidated and included in the final merged document.

To merge a password-protected PDF, you must provide the correct password in the API request to allow us to decrypt and process the file.