Split PDF in multiple files

If you find any problem with API, please make an issue at GitHub


4.4 How to split a pdf into multiple files using API Rest


URL

To split PDF using our API Rest is necessary to perform a POST call to the following URL (ENDPOINT):

https://getoutpdf.com/api/tool/split-pdf


GET Parameters

Our Rest API does not have operations via GET parameters


POST Parameters

  • api_keyApi key generated for your license. You can see your api key
    (string, required)
  • pdf_inSource PDF encoded in base64
    (string, required)
  • splitNumber of pages of every splitted part of the pdf.
    (integer, optional)
  • start_pageThe page to start at
    (integer, optional)
  • end_pageThe page to stop at
    (integer, optional)

Some examples
  • Split 0, Start 0, End 0 => it will split the pdf page by page.
  • Split 2, Start 0, End 0 => it will split the pdf in pieces of 2 pages each except the last which will contain 1 page only.
  • Split 0, Start 5, End 0 => it will provide a pdf containing all pages of the source pdf starting at page 5
  • Split 0, Start 5, End 10 => it will provide a pdf containing all pages from 5 to 10 of the source pdf
  • Split 2, Start 5, End 10 => it will provide 3 pdf's containing all pages from 5 to 10 of the source pdf 2 pages each

You can make a POST call using the HTML Header application/x-www-form-urlencoded, with the parameters described above.

Or you can send parameters via the JSON format, using the HTML Header application/json:

{
    "api_key" : "...",          // string, required
    "pdf_in" : "...",           // string, required
    "split" : 1,                // integer, optional, default: 1
    "start_page" : 2,           // integer, optional, default: 1
    "end_page" : 3              // integer, optional
}

Example

{
    "api_key" : "64b5d1054b69e676b9984d8406c5209a6ba78...",
    "pdf_in" : "JVBERi0xLjQNJeLjz9MNCjYgMCBvYmo8PC9I...",
    "split" : 1,
    "start_page" : 2,
    "end_page" : 3
}

Response

If the operation is successful the response is a JSON with the following structure:

{
    "api_key": "...",                   // string - Api key used for your license
    "pdf_base64": ["...", "...", ...],  // array(string) - Array of PDF files encoded in base64
    "tokens_used": "...",               // integer - Tokens used in operation
    "tokens_left": "..."                // integer - Tokens left
}

Errors

If an error in sending parameters occurs, the response is a JSON with the following structure:

{
    "errors": {
        "param1": [     // string - Parameter name that generated the error
            "message"   // string - Error description
        ],
        "param2": [
            "message"
        ],
        ...
        "paramN": [
            "message"
        ]
    }
}

If a operation error occurs, the answer will be a JSON with the following structure:

{
    "errors": [
        "message1",
        "message2",
        ...
        "messageN"
    ]
}