الانتقال إلى المحتوى الرئيسي

PDF Tools API

Split PDF API

Extract page ranges or divide large PDFs automatically so your app can produce focused packets, attachments, or archives.

Credits

1 Credit / call

1 Credit per successful API request. Failed processing attempts are refunded automatically.

Pricing

1,000 Credits = $1

Every signed-in user receives 100 free API Credits each month.

Endpoint

/api/external/pdf-tools/split-pdf

Use your API Key in the x-api-key header.

cURL example

curl -X POST https://itextmaster.com/api/external/pdf-tools/split-pdf \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"mode":"ranges","ranges":[{"start":1,"end":3},{"start":4,"end":8}]}' \
  --output split-results.zip

Node.js example

import { writeFile } from 'node:fs/promises';

const response = await fetch('https://itextmaster.com/api/external/pdf-tools/split-pdf', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.ITEXTMASTER_API_KEY
  },
  body: JSON.stringify({
  files: [
    { name: 'input.pdf', dataBase64: 'JVBERi0xLjcK...' }
  ],
  options: {"mode":"ranges","ranges":[{"start":1,"end":3},{"start":4,"end":8}]}
})
});

if (!response.ok) {
  throw new Error(await response.text());
}

await writeFile('split-results.zip', Buffer.from(await response.arrayBuffer()));

Python example

import os
import requests

response = requests.post(
    'https://itextmaster.com/api/external/pdf-tools/split-pdf',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
    },
    json={
        'files': [
            {'name': 'input.pdf', 'dataBase64': 'JVBERi0xLjcK...'}
        ],
        'options': {'mode':'ranges','ranges':[{'start':1,'end':3},{'start':4,'end':8}]}
    },
)
response.raise_for_status()

with open('split-results.zip', 'wb') as f:
    f.write(response.content)

Error codes

401invalid_api_key

The x-api-key header is missing, invalid, or has been rotated.

402insufficient_credits

The account does not have enough API Credits for the request.

422pdf_tool_processing_failed

The file, options, or PDF structure could not be processed.

Limits

  • Requires one valid PDF file.
  • Returns ZIP output when one request creates multiple files.
  • Page ranges must refer to pages that exist in the input PDF.

Example output

split-results.zip with X-Credits-Charged: 1 and X-Credit-Balance response headers.

X-Credits-Charged: 1

X-Credit-Balance: 99

Content-Disposition: attachment; filename="split-results.zip"

FAQ

Does the Split PDF API return one file or many?

It returns a ZIP file for multi-output split jobs and includes Credits headers on successful responses.

Can I extract custom page ranges?

Yes. Use ranges such as 1-3 and 4-8 in the options payload.

Does a failed split consume Credits?

No. Failed processing attempts are refunded automatically.

Start with 100 free API Credits

Create an API Key, test Split PDF API, and buy more Credits only when automation volume grows.