Answer: POST /api/v1/tools/url-to-pdf takes JSON with a public url and an options object, loads the page in headless Chromium and returns the PDF in a job envelope; two credits. Private and metadata addresses are refused before anything is fetched. The options below set the viewport, when the capture fires and the page geometry; a value out of range is a 400 naming the field, raised before any job or credit moves.
Request
Options travel in a nested options object. The setting that most often decides whether the PDF looks right is wait_until: a page captured before its JavaScript finishes renders blank or half-loaded, which networkidle (the default) and wait_extra_ms are there to prevent.
curl -X POST https://www.ashdocs.com/api/v1/tools/url-to-pdf \
-H "X-API-Key: ash_test_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/report",
"options": { "format": "Letter", "wait_until": "networkidle", "wait_extra_ms": 500 } }'When there is no Chromium
On a host without a Chromium binary the page is rendered by WeasyPrint instead, and the job's render info says so — it is never a silent switch.
Options
Generated from the URL renderer's option parser.
| Sent in | Key | What it does |
|---|---|---|
| options | viewport.width / viewport.height | Browser window in CSS pixels. Default 1280 × 800; width 320–3840, height 320–4320. |
| options | wait_until (alias wait_for) | When to capture: networkidle, load, domcontentloaded. Default networkidle. |
| options | wait_extra_ms | Extra wait after the load condition, 0–10000 ms. Default 0. |
| options | scroll_lazy | Default true: scrolls the page first so lazy-loaded images load. |
| options | print_background (alias printBackground) | Default true: print background colours and images. |
| options | media | screen (default) or print — which CSS media the page is rendered as. |
| options | format (alias page_size) | Paper size: A4, Letter, Legal, A3, A5. Default A4. |
| options | landscape | Default false. |
| options | prefer_css_page_size | true lets the page's own @page size win over format. Default false. |
| options | scale | Render scale, 0.1–2.0. Default 1.0. |
| options | margin_mm | Page margin, 0–50 mm. Default 10. |
Frequently asked questions
Why is my PDF blank or half-loaded?
The capture fired before the page finished rendering. Keep wait_until at networkidle and add wait_extra_ms for pages that render after the network goes quiet.
Can I capture the page's print stylesheet?
Yes — set media to print. The default is screen.
Can it fetch an internal URL?
No. Private, loopback and metadata addresses are refused before the fetch.