{
  "name": "pdf-split",
  "summary": "Extracts a 1-indexed page selection (e.g. \"1,3-4\") from a PDF into one new PDF, returned base64-encoded. Maximum output PDF size: 25 MiB before base64 encoding.",
  "rationale": "Splitting a PDF needs a real PDF library and a hardened fetch: an agent that pulls the URL itself walks past every SSRF control, and the output must be byte-reproducible, which a naive save is not.",
  "family": "documents",
  "price_usd": "0.005",
  "free": false,
  "timeout_ms": 30000,
  "max_timeout_seconds": 51,
  "input_schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "maxLength": 2048,
        "format": "uri",
        "description": "Absolute http(s) URL of the source PDF, up to 2048 characters; redirects are followed, the body must start with %PDF-, and an encrypted file is refused."
      },
      "ranges": {
        "type": "string",
        "minLength": 1,
        "maxLength": 512,
        "description": "Comma-separated 1-indexed pages or inclusive ranges such as \"1,3-4\", up to 512 characters; pages are emitted in the order written, repeats are kept, and a descending range or a page past the end is an error."
      }
    },
    "required": [
      "url",
      "ranges"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/documents/split-five-pages.pdf",
    "ranges": "1,3-4"
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/documents/split-five-pages.pdf",
    "source_pages": 5,
    "pages": 3,
    "bytes": 1392,
    "pdf_base64": "JVBERi0xLjcKJYGBgYEKCjQgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUK..."
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}