Screenshots & PDF
Get a picture of the page next to the data: options.screenshot returns a PNG or JPEG, options.pdf a PDF. Both show the page as it is after the actions. To capture it at other moments too (before a click, after a captcha), add screenshot and pdf actions: each one returns its file in its action's result.
Actions
Data
Files come back in the response, base64-encoded:
"screenshot": { "content_type": "image/png", "data": "iVBORw0KGgoAAAANSUhEUgAA…" },
"pdf": { "content_type": "application/pdf", "data": "JVBERi0xLjQKJdPr6eEKMSAwIG9i…" }Options
screenshot accepts true or an object:
| Property | Type | Default | Description |
|---|---|---|---|
full_page | boolean | false | The whole page instead of the window (viewport, 1920 × 1080 by default) |
selector | string | — | Only this element. Can't be combined with full_page |
type | string | "png" | png or jpeg |
quality | integer | — | jpeg only, 1 to 100 |
pdf accepts true or an object:
| Property | Type | Default | Description |
|---|---|---|---|
format | string | "A4" | A3, A4, A5, Letter, Legal or Tabloid |
landscape | boolean | false | Landscape orientation |
"options": {
"browser": true,
"screenshot": { "selector": "#products", "type": "jpeg", "quality": 70 },
"pdf": { "format": "Letter" }
}Without a browser, or with one that can't
Screenshots work with every engine but Lightpanda, which doesn't draw pages. PDFs need Chromium or CloakBrowser in headless mode. When what you asked for can't be done where the page was loaded, including without a browser, the API loads the page's HTML into an installed browser that can, and takes the screenshot or PDF there. A warning says so:
Actions
Data
"warnings": [
"no browser: the screenshot was rendered by chromium from the page's HTML, without JavaScript"
]That copy loads the page's images and styles through the same proxy, but doesn't run its scripts: what JavaScript would have added only shows if a browser loaded the page first. A screenshot of a selector that isn't on the page fails the request with ACTION_FAILED.
In a fallback strategy, "screenshot": false and "pdf": false turn them off.
Captures are also kept in storage for a while and linked from the response (url): see Stored files.