Skip to content

How to capture a web page from the command line: Page Scanner CLI vs. headless Chrome vs. Playwright vs. wkhtmltopdf vs. SingleFile

Five ways to turn a URL into a file without touching the browser, compared on what they output, whether they can see a page you are signed in to, and what you have to install first.

A capture you can script is a capture you can schedule, batch and put in a pipeline. Every tool below turns a URL into a file from a shell. They differ in what that file is, whether the page they see is the page you see when you are logged in, and how much you install to get there. Here are the five, and when each is the right one.

Five tools at a glance

Page Scanner CLIHeadless ChromePlaywright CLIwkhtmltopdfSingleFile CLI
The file you getPDF, PNG or JPEGPDF, or a PNG of the viewportPNG, JPEG or WebP; PDFPDF, or an imageone HTML file
Text you can select✓ in the PDF✓ in the PDF✓ in the PDF
Sees the page you are signed in to✓ it runs in your Chromea separate profile via --user-data-dir✓ with a saved profile
Looks like the page on screen✓ one layout, on screen mediathe print layout✓ screenshot; the PDF is print media✗ its own engine, Qt WebKit
Whole page in one goPDF ✓; screenshot is the window--full-page
Choose the width and the paper--page-width, --page-size--window-sizein the browser it launchespage size optionsn/a
Machine-readable result--json, six exit codesa filea filea filea file
What you installNode 24; Chrome with the extensionChromeNode and the package, plus its browsersone binaryDeno and a Chromium browser
Licence and pricefreefreeApache-2.0LGPLv3AGPL

✓ yes, ✗ no, — the tool's own documentation does not say.

Page Scanner CLI

npx @page-scanner/cli pair
npx @page-scanner/cli scan --url https://en.wikipedia.org/wiki/PDF --out ./pdf.pdf

The capture itself is done by the Page Scanner extension, in the Chrome you are already signed in to: the command line is the other half, listening on 127.0.0.1 for that extension and turning scan into a file on your disk. So a page behind a login is a page you are logged in to, no second browser starts, and the file is the same PDF the editor makes, text selectable and artwork vector, laid out at the window's width or narrowed to A4 or Letter with --page-width so it prints at 1:1. --format png or jpeg gives an image, --page-size auto one long page.

It is built for scripts: stdout carries the answer and nothing else, one line with the absolute path of the file, --json puts exactly one JSON document there for success and failure alike, and the exit code says which kind of failure, from wrong arguments to no browser connected. It needs Node.js 24 or newer, Chrome with the extension, and a one-time pairing, which is a port and a token pasted into the extension's settings page. Chrome shows its debugging bar for each scan, as it does when you click the icon.

Headless Chrome

chrome --headless --print-to-pdf https://www.chromestatus.com/
chrome --headless --screenshot --window-size=1280,1696 https://www.chromestatus.com/

Nothing to install if Chrome is there. --print-to-pdf writes the page as Chrome would print it, so the text is real and the layout is the print stylesheet's, not the screen's. --screenshot writes a PNG of the window, and Chrome's own guide notes that a full-page screenshot is "a tad more involved". By default it is a fresh, logged-out browser; --user-data-dir points it at a profile, and Chrome will not share the one that is already open. The right tool when the page is public and you want zero dependencies.

Playwright CLI

playwright-cli screenshot --full-page --filename=full-page.png
playwright-cli pdf --filename=page.pdf

Playwright's command line drives a browser it launches and gives you the screenshot as PNG, JPEG or WebP, full page with --full-page, and a PDF, which works in headless Chromium. Because it is the same engine as the test framework, anything you can automate you can do before the capture: log in, click, wait. That is the trade: you install Node, the package and its browsers, and you are scripting a browser rather than capturing yours.

wkhtmltopdf

wkhtmltopdf converts HTML to PDF and images through the Qt WebKit rendering engine, headless, with no display, under the LGPLv3, as a single binary for most platforms. It has been the workhorse of server-side PDF generation for years, and its strength is exactly that: a build server with no browser can still make a PDF. Its engine is not the one your browser uses, so a modern page can render differently from what you see, and it sees the page a visitor with no cookies sees.

SingleFile CLI

single-file https://www.wikipedia.org wikipedia.html

Not a PDF tool, and worth having next to them. SingleFile CLI "saves a faithful copy of a complete web page in a single HTML file", styles and images included, through a headless Chromium browser, running on Deno. For a page behind a login its documentation says to create a profile, log in to the site in that browser window, quit to save it, and reuse the profile for the capture. The output is a web page, which is the best archive format there is and the least useful thing to hand someone who asked for a PDF.

Which should you use?

Use Page Scanner CLI if the page is behind your login, or the file has to look like the page on your screen and still hold real text, and you want a result a script can parse.

Use headless Chrome if the page is public, the print layout is fine, and you do not want to install anything.

Use Playwright CLI if the capture comes after steps in the browser: a login flow, a click, a wait for something to load.

Use wkhtmltopdf if the PDFs are made on a server with no browser and the pages are yours, built to render well in it.

Use SingleFile CLI if you are archiving, and a browser is where the copy will be opened.

Frequently asked questions

Which ones can run without a browser installed? wkhtmltopdf, with its own engine. Everything else here drives Chrome, Chromium or a browser it downloads.

Can Page Scanner's CLI run on a server? It needs a Chrome with the extension installed and paired, so it belongs on a machine with a browser, which is the point: the browser's logins are what it captures.

Which one does an AI agent use? Page Scanner has an MCP server that is these four commands as tools; this post compares it with Playwright MCP, Chrome DevTools MCP and Puppeteer.

Where this comes from

Page Scanner is a Chrome extension. Add it to Chrome.