eCom Learning Solutions / Developer toolsOpen source
Documentation/Generation/Merge PDF pages
03 / COMBINE

Merge supplied PDF pages

Send your PDF files to POST /api/v1/pdfs/merge. The API uses iTextSharp PdfCopy to copy PDF pages into one document. Files are processed in array order; page selections are processed in the order you provide.

JSON · merge request structure
{
  "documents": [
    { "pdfBase64": "BASE64_OF_FIRST_PDF", "pages": [3, 1, 2] },
    { "pdfBase64": "BASE64_OF_SECOND_PDF", "pages": [1] }
  ],
  "fileName": "combined.pdf",
  "pageNumbers": { "format": "{page} / {total}" }
}
FieldTypeBehaviour
documentsarray1–25 PDF objects, in output order.
pdfBase64stringBase64 encoded PDF bytes, without a data URL prefix. At most 10 MB decoded per file.
pagesinteger arrayOne-based page numbers. Omit or use null for all pages. An empty list is invalid. Repeats are allowed, e.g. [2, 1, 2].
fileNamestring, optionalDownload filename, up to 80 characters; sanitized by the API.
pageNumbersobject, optionalStamp your supplied format on the merged result.

To provide individual pages, supply one-page PDFs, or select pages from larger PDFs. The result may contain up to 500 pages. The 20 MiB request limit includes base64 and JSON overhead. Uploaded files must be valid, unencrypted PDFs; active content and attachments are rejected.

PowerShell + cURL · merge PDFs from your current folder
$baseUrl = '__API_ORIGIN__'
$first = [IO.Path]::GetFullPath('.\first.pdf')
$second = [IO.Path]::GetFullPath('.\second.pdf')
$request = @{
  documents = @(
    @{ pdfBase64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes($first)); pages = @(1) }
    @{ pdfBase64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes($second)) }
  )
  fileName = 'combined.pdf'
} | ConvertTo-Json -Depth 10
$requestPath = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName())
[IO.File]::WriteAllText($requestPath, $request, [Text.UTF8Encoding]::new($false))
try {
  curl.exe --fail-with-body -X POST "$baseUrl/api/v1/pdfs/merge" `
    -H 'Content-Type: application/json' `
    --data-binary "@$requestPath" --output '.\combined.pdf'
  if ($LASTEXITCODE -ne 0) { throw 'PDF merge failed.' }
} finally { Remove-Item -LiteralPath $requestPath }

Want a merge demo?
The hosted source archive includes examples/merge-pages.ps1 and its mock request files. The generic application download contains the five template request examples only.

Existing clients may keep using documentsBase64: ["BASE64_PDF_1", "BASE64_PDF_2"] to include every page. Send exactly one of documents or documentsBase64.

Page sizes, rotation, and content are copied without rasterizing. This is a page assembly operation: document-level features such as bookmarks, digital signatures, and interactive form behaviour are not guaranteed to carry over.

Open merge workspace ↗