webcapture Get a free key

Print PDF page ranges with curl

A long page prints to many pdf pages, and pageRanges picks which of them ship: one body field between the POST and the same two-call pattern.

pageRanges counts the printed pdf pages, not screenfuls: a long report that renders to twelve A4 pages can ship as its first three plus the table on page seven. The field applies to pdf output, which is the default format, so the body below sends nothing else.

The recipe

ORIGIN="https://webcapture.io"

RECEIPT=$(curl -sS -X POST "$ORIGIN/v1/convert" \
  -H "Authorization: Bearer wc_your_key" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/", "pageRanges": "1-3,7"}')
echo "$RECEIPT"
# {"id": "cnv_77d1e0aa", "bytes": 41207, "attempts": 1,
#  "remaining": 48, "sourceUrl": "https://example.com/", "sourceType": "url",
#  "download": ".../v1/conversions/cnv_77d1e0aa.pdf"}

ID=$(printf '%s' "$RECEIPT" | sed -E 's/.*"id": *"([^"]+)".*/\1/')
case "$ID" in cnv_*) ;; *) echo "convert failed: $RECEIPT" >&2; exit 1 ;; esac

curl -sS -H "Authorization: Bearer wc_your_key" \
  -o report-excerpt.pdf \
  "$ORIGIN/v1/conversions/$ID.pdf"

The render still walks the whole page, so bytes reflects the trimmed document, not the full render. Ranges accept digits, spaces, commas, and hyphens: 1-3,7 is pages one to three plus seven, and a range past the last printed page just stops at the end.

Same-key GET: 401 without it; 404 for another key.

The fields this recipe uses

Related

Method

Source: convert field reference, checked 2026-10-05. Corrections.