Split PDF API

Split multiple PDF documents into new PDFs. Use our PDF page splitting API to select pages from an existing PDF file and create a new document.

Try It Out

This example will split your document into two documents. The first PDF will contain all pages except the last five, and the second PDF will contain the remaining five pages.

1

Use Your Free Credits

Sign up to get 100 free credits, or log in to automatically add your API key to sample code.

Add a File

Add a PDF named document.pdf to your project folder. You can also use our sample file. The file name is case sensitive. Make sure the file name matches the file name in the sample code.

Run a Command

Copy the curl command and run it in that same folder via the terminal or your editor’s terminal. This sample code uses a zero index to call on the specific pages of a document. Change where your file is split by adjusting the end and start numbers. If you want your first file to end on page 3 and the second file to start on page 4, set end to 2 and start to 3. Running this code with your live API key will use two credits.

View the Results

Open first_half.pdf in your project folder to view the results.

Shell
    curl -X POST https://api.pspdfkit.com/build \
        -H "Authorization: Bearer your_api_key_here" \
        -o first_half.pdf \
        -F document=@document.pdf \
        -F instructions='{
            "parts": [
              { "file": "document", "pages": { "end": -6 } }
            ]
          }'

    curl -X POST https://api.pspdfkit.com/build \
        -H "Authorization: Bearer your_api_key_here" \
        -o second_half.pdf \
        -F document=@document.pdf \
        -F instructions='{
            "parts": [
              { "file": "document", "pages": { "start": -5 } }
            ]
          }'

            
Using Postman? Download our official collection and start using the API with a single click. Read more 

Your API Key