Screenshots
The HTML, URL and Markdown routes, but the answer is an image instead of a PDF. For previews, social cards and thumbnails.
POST https://api.pdfdispatch.com/v1/screenshot/html
POST https://api.pdfdispatch.com/v1/screenshot/url
POST https://api.pdfdispatch.com/v1/screenshot/markdown
Each takes the same inputs as its PDF route: an index.html with its files (HTML), a url
(URL), or a template and Markdown files (Markdown). A screenshot
counts as one PDF on your plan.
Image options
| Field | Type | Default | What it does |
|---|---|---|---|
width | integer | 800 | The width of the browser window, in pixels. |
height | integer | 600 | The height of the browser window, in pixels. |
clip | boolean | false | Cut the picture to width × height. Without it, the whole page is captured, however long. |
selector | string | – | Capture only the first element that matches this CSS selector, for example #chart. No visible match is an error (400). Wins over clip. |
format | string | png | png, jpeg or webp. |
quality | integer | 100 | 0 to 100, for jpeg and webp only. |
optimizeForSpeed | boolean | false | Encode faster, at the cost of a bigger file. |
deviceScaleFactor | number | 1.0 | Pixel density. 2 gives a sharp image for high-resolution screens, twice as wide and high. |
omitBackground | boolean | false | A transparent background where the page has none (png and webp). |
The browser options also apply: waiting, emulated media, cookies and headers and failure checks. Paper options do not.
Example
A 1200 × 630 social card, sharp on high-resolution screens:
curl --fail-with-body \
--header "Authorization: Bearer $PDD_KEY" \
--form '[email protected];filename=index.html' \
--form width=1200 --form height=630 --form clip=true \
--form deviceScaleFactor=2 \
--form format=webp --form quality=90 \
--output card.webp \
https://api.pdfdispatch.com/v1/screenshot/html
;filename=index.html uploads a local file under the name the route expects.