Skip to main content

Split PDF

POST https://api.getdocuforge.dev/v1/pdf/split Split a single PDF into multiple documents based on page ranges.

Request Body

ParameterTypeRequiredDescription
pdfstringYesBase64-encoded PDF document
rangesnumber[][]NoArray of page ranges. Each range is [start] or [start, end] (1-indexed, inclusive). If omitted, splits into individual pages.
outputstringNo"url" (default) or "base64"

Range Examples

RangeResult
[1]Page 1 only
[1, 3]Pages 1 through 3
[[1, 2], [5, 8]]Two documents: pages 1-2 and pages 5-8

Example

curl -X POST https://api.getdocuforge.dev/v1/pdf/split \
  -H "Authorization: Bearer df_live_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64-encoded-pdf>",
    "ranges": [[1, 3], [4, 6]],
    "output": "url"
  }'

Response (URL mode)

{
  "parts": [
    { "url": "https://cdn.getdocuforge.dev/gen_abc123.pdf", "file_size": 45230 },
    { "url": "https://cdn.getdocuforge.dev/gen_def456.pdf", "file_size": 32100 }
  ],
  "total": 2
}

Response (base64 mode)

{
  "parts": [
    { "data": "<base64-encoded-pdf>", "file_size": 45230 },
    { "data": "<base64-encoded-pdf>", "file_size": 32100 }
  ],
  "total": 2
}

Errors

StatusCodeDescription
400VALIDATION_ERRORInvalid ranges or PDF exceeds size limit
401UNAUTHORIZEDInvalid or missing API key
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORServer error during split