Docs
Dashboard
Guides / WebBeta

PDF

Print any page to a PDF, the way Chrome's Save as PDF does.

POST /v1/pdf opens a URL in a fresh browser and prints it to PDF, the way Chrome’s Save as PDF does. The response body is the PDF.

Request

curl -X POST https://api.boxline.dev/v1/pdf \  -H "x-api-key: $BOXLINE_API_KEY" \  -H "content-type: application/json" \  -d '{"url": "https://example.com", "paper": "Letter"}' \  -o page.pdf
FieldDefaultDescription
urlrequiredThe page.
paper"A4""A4", "A3", "A5", "Letter", "Legal" or "Tabloid".
landscapefalseLandscape instead of portrait.
printBackgroundtruePrint background colours and images.
scale1Zoom of the printed page, from 0.1 to 2.

It also takes the options every web API shares:

FieldDefaultDescription
waitUntil"load"When the page counts as loaded: "load", "domcontentloaded", "networkidle" (no network traffic for a moment) or "commit".
delayMs0Extra wait after the page loads, up to 10,000 ms. Useful for pages that draw late.
timeoutMs30000How long to wait for the page, from 1,000 to 120,000 ms.
proxynoneLoad the page through a residential, datacenter or your own proxy, e.g. { "type": "residential", "country": "FR" }. The IP changes with every request unless you ask for "ip": "sticky". See Proxies.
browserstandardThe page’s clock and language, e.g. { "mode": "realistic" } to follow the proxy’s country, or { "locale": "fr-FR", "timezone": "Europe/Paris" }. See Browser mode.
blockAdsfalseRefuse requests to ad and tracker sites while the page loads: faster, with less clutter, and no proxy data spent on them. See Ad and cookie-banner blocking.

Response

The body is the PDF (application/pdf). It has the same headers as a screenshot: x-final-url, x-page-status, x-page-title, x-page-captcha and x-render-ms. See Screenshot.

Errors

Status and codeWhat it means
502 page_unreachableThe page could not be loaded. The message names the host and Chrome’s reason, e.g. could not load example.com: ERR_NAME_NOT_RESOLVED. When Chrome’s reason is a generic one, the message adds the real one in words, e.g. (the name does not resolve (DNS)). See why a page did not load.
504 page_timeoutThe page did not finish loading within timeoutMs. Try a longer time or another waitUntil.
402 feature_not_in_planYour plan does not include this API, or the kind of proxy you asked for.
429 rate_limitedToo many requests. Wait for the seconds in Retry-After. See Rate limits.

Every field is in the API reference: Make a PDF.

These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.