Skip to content
ComPDF
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Insert PDF Pages API

Insert pages from another PDF into the main PDF.

Feature

The ComPDF Self-hosted accepts files and a request JSON string through multipart/form-data, forwards the parameters to the private PDF SDK, and streams the result file back on success.

Synchronous Request

ItemValue
Authenticationx-api-key: your_api_key_here
Request URLPOST http://localhost:8080/api/v1/process/pdf/insert-from-pdf
Content typemultipart/form-data
Success responseResult file stream

Request Parameters

ParameterTypeDescriptionRequired
fileFileTarget PDF file.Yes
insertFileFilePDF file to insert into the target PDF.Yes
requestStringJSON string containing the PDF SDK parameters below. If omitted, remaining non-file form-data fields are forwarded as the request object.No

Request Object Parameters

Put the following fields in the request JSON string.

ParameterTypePurpose
indexNumberOne-based insertion position.
sourcePageRangesString[]Page ranges selected from the PDF being inserted. Empty means all pages.
targetPasswordStringPassword for the main target PDF.
insertPasswordStringPassword for the inserted PDF.
outputFileNameStringOptional output filename. When present, it is used as the preferred download filename.

Request Example

bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/insert-from-pdf" \
  -H "x-api-key: your_api_key_here" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'request={"index":1,"sourcePageRanges":["1-2"],"targetPassword":"","insertPassword":""}'

Response

On success, the API returns the processed file stream with Content-Type and Content-Disposition headers. On failure, the ComPDF Self-hosted returns a normalized error JSON response.