PDFDispatch Docs

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

FieldTypeDefaultWhat it does
widthinteger800The width of the browser window, in pixels.
heightinteger600The height of the browser window, in pixels.
clipbooleanfalseCut the picture to width × height. Without it, the whole page is captured, however long.
selectorstring–Capture only the first element that matches this CSS selector, for example #chart. No visible match is an error (400). Wins over clip.
formatstringpngpng, jpeg or webp.
qualityinteger1000 to 100, for jpeg and webp only.
optimizeForSpeedbooleanfalseEncode faster, at the cost of a bigger file.
deviceScaleFactornumber1.0Pixel density. 2 gives a sharp image for high-resolution screens, twice as wide and high.
omitBackgroundbooleanfalseA 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.