Guide

Screenshots and PDFs

A picture of the page or of one element. A PDF straight to a file. Which providers do it without a session

Screenshot

shell
browsers screenshot https://example.com -o page.png -p playwright
text
ℹ Screenshot via playwright...
✔ Screenshot saved to /home/you/page.png

Full page by default. --no-fullPage keeps it to the viewport, --width and --height set that viewport, -f picks png, jpeg or webp.

In TypeScript it's provider.screenshot({ url, fullPage, format, selector, viewport }), and the result carries the image as base64 in data plus its mimeType. A provider with statelessScreenshot false wants a session for that, same deal as Kernel and scrape. The CLI and the tools open one for you.

One element

shell
browsers screenshot https://httpbin.org/forms/post -o form.png --selector form

--selector captures the first element that matches, not the page. Cloudflare, Browserless and Playwright can do it, the flag is elementScreenshot. Leave the provider out and the first configured one of those gets the job. Name another one and it refuses. It won't quietly hand you the whole page and pretend.

A selector that matches nothing is the vendor's error, passed through. Browserless says Element not found on page!, which is at least honest.

For a model

browsers_screenshot returns the image itself, so a model that reads images sees the page. A capture whose base64 runs past 5 MB can't go back inline, so pass path and it writes a file instead. path never overwrites. An existing file is an error, not a surprise.

selector and fullPage: true together are an InvalidInputError. Pick one.

PDF

shell
browsers pdf https://example.com -o page.pdf -p playwright
text
ℹ Generating PDF via playwright...
✔ PDF saved to /home/you/page.pdf

Cloudflare, Browserless and Playwright print PDFs. --landscape turns the page. browsers_pdf always writes to path, because a PDF can't go back to a model anyway, and an existing file is still an error.