// api reference

Extract Pages from PDF API

Pull specific pages out of a PDF by a single page number or a range like 2-4. Ideal for splitting documents or isolating sections into a new, smaller file.

How it works

Every PDF tool runs as a small CustomJS function using our built-in pdfUtils. Write a few lines of JavaScript, deploy once, and you get a private API endpoint you can call from anywhere. Make.com, n8n, or plain curl.

01

Paste the function below into the editor at app.customjs.space.

02

Set the Response Type to PDF and deploy.

03

Call your function URL with the x-api-key header.

The CustomJS function

Import EXTRACT_PAGES_FROM_PDF from ./utils and return its result. Remember to set the function's Response Type · PDF

const { EXTRACT_PAGES_FROM_PDF } = require('./utils');

const pdfInput = input.file || input.url;

return EXTRACT_PAGES_FROM_PDF(pdfInput, input.pageRange);

Calling your endpoint

POST to your function URL. Pass the source PDF either as a public URL or a Base64 string. The request payload is capped at 6 MB.

Request body

FieldTypeDescription
urlstringPublic URL of the source PDF. Provide either url or file.
filestringBase64-encoded PDF binary (payload max 6 MB).
pageRangestringRequired. Page number or range to extract, e.g. "1" or "2-4".

Example. Source from a URL

curl -X POST https://e.customjs.io/<your-function-id> \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "url": "https://css4.pub/2017/newsletter/drylab.pdf",
    "pageRange": "1"
  }' --output first-page.pdf

Example. Source as Base64

curl -X POST https://e.customjs.io/<your-function-id> \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "file": "JVBERi0x..........EyNzg3CiUlRU9GCg==",
    "pageRange": "1-2"
  }' --output pages.pdf

Other PDF tools

// try it first

Prefer to play before you code?

Open the interactive playground on the product page. Generate PDFs live, tweak the code, and copy the generated curl or SDK snippet straight into your stack.

extract-pages-from-pdf.curl
curl -X POST https://e.customjs.io/<your-function-id> \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "url": "https://css4.pub/2017/newsletter/drylab.pdf",
    "pageRange": "1"
  }' --output first-page.pdf

600 free operations / month · no credit card

Frequently Asked Questions