Skip to content
ComPDF

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

PDF Merge API

BASE URLhttps://api-server.compdf.com/server/

❖ Feature Description

Merge multiple PDF files into a single PDF in order, with per-file page ranges and passwords.

❖ Request Mode

Synchronous Request (Sync)
The API returns the result file directly after processing. Recommended for small files and real-time interactive scenarios that need immediate feedback.
Asynchronous Request (Async)
The API first returns task acceptance information, then you query progress and results with taskId. Suitable for large files and batch workloads.
Secure Request Mode
Upload and process files through secure mechanisms such as pre-signed URLs. Suitable for high-security and privacy compliance scenarios.

▎Call Flow

1Upload file
2Call API (sync)
3Get result URL
4Download file

▎Usage Limits

Download validity24 hours

Execute synchronously

POSThttps://api-server.compdf.com/server/v2/process/pdf/merge

❖ Request Parameters

Authentication credential sent in the header: x-api-key

Body Parameters multipart/form-data

No file selected
List of PDF files to merge (at least 2). Submission order determines merge order.
Default open password. Use this if all source PDFs share the same password; otherwise use passwords[] for per-file passwords.
API error message language. 1 = English, 2 = Chinese (default).
File 1
File 2
Each row maps 1:1 to a file in the upload list above; fill in one row per file in the same order.
Page ranges corresponding one-to-one with the file[] list; provide one entry for each file. Page numbers start at 1. Use "all" or a format such as "1-3,6", with multiple segments separated by commas.
File 1
File 2
Each row maps 1:1 to a file in the upload list above; fill in one row per file in the same order.
Open passwords corresponding one-to-one with the file[] list. Use an empty string as a placeholder for files that do not require a password.
Output PDF file name. Defaults to merged.pdf if not provided.

❖ Response Properties

FieldTypeDescription
codeStringBusiness status code
msgStringMessage
dataArrayResponse data
data[].fileKeyStringUnique key of the file in the storage system.
data[].taskIdStringTask ID. Returned after task creation; used to launch conversion or query task status.
data[].fileNameStringSource file name. Required in presigned mode to generate the object storage upload URL.
data[].downFileNameStringOutput file name after conversion.
data[].fileUrlStringSource file storage URL or object storage key.
data[].downloadUrlStringFile download URL
data[].sourceTypeStringSource file type or feature category, e.g. pdf, docx, img, documentAI, idp.
data[].targetTypeStringTarget file type or feature, e.g. docx, pdf, split, ocr.
data[].fileSizeIntegerSource file size in bytes.
data[].convertSizeIntegerConverted file size in bytes.
data[].convertTimeIntegerConversion time for a single file, typically in milliseconds.
data[].statusStringFile processing status. Common values: success, failed, processing, etc.
data[].failureCodeStringError code when file conversion fails.
data[].failureReasonStringError reason when file conversion fails.
data[].fileParameterStringConversion parameter JSON string submitted when creating the task.
🔗Request Example
curl --request POST \
  --url https://api-server.compdf.com/server/v2/process/pdf/merge \
  --header 'x-api-key: YOUR API-KEY' \
  --form [email protected] \
  --form [email protected]
Response Example
200 OK
{
  "code": "200",
  "msg": "success",
  "data": [
    {
      "fileKey": "<string>",
      "taskId": "<string>",
      "fileName": "<string>",
      "downFileName": "<string>",
      "fileUrl": "<string>",
      "downloadUrl": "<string>",
      "sourceType": "<string>",
      "targetType": "<string>",
      "fileSize": 0,
      "convertSize": 0,
      "convertTime": 0,
      "status": "<string>",
      "failureCode": "<string>",
      "failureReason": "<string>",
      "fileParameter": "<string>"
    }
  ]
}