Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use PowerShell to launch a small Playwright script: a headless browser renders the HTML, then saves a screenshot as PNG, JPEG, or WebP. This works for a local HTML file or a web page, and supports viewport, full-page, and element captures. PowerShell handles paths and job orchestration; Playwright does the browser rendering.
What you need
Install Node.js on the computer or build agent that will run the capture, then install Playwright and its browser binaries in a project directory. Playwright provides one automation API across browsers, and launches headless browsers by default, which suits scheduled scripts and CI. Microsoft Edge’s developer documentation demonstrates the same essential flow: launch a browser, create a context and page, navigate, take a screenshot, and close the browser.
- Install a current Node.js release appropriate for your operating system.
- In PowerShell, create and enter a working directory, then initialize an npm project and install Playwright:
mkdir HtmlCapture
Set-Location HtmlCapture
npm init -y
npm install playwright
npx playwright install chromium
The last command installs Playwright’s bundled Chromium browser. The package and browser are separate prerequisites: installing the JavaScript package alone does not guarantee the browser binary is present. On Linux CI images, the browser may also need operating-system libraries; use Playwright’s installation guidance for the machine’s platform if launch reports missing shared libraries.
Bundled Chromium is the reproducible default for automation because Playwright installs and controls the browser version it expects. If your output must match branded Microsoft Edge, Playwright can launch an Edge channel when Edge is installed, but installed-browser policies or enterprise management can affect whether automation works. Compare the bundled browser and the target channel with representative pages before relying on pixel-identical output.
#1 Best Overall
- Customized Thermal Inkless Printer: The Inkless sticker printer uses thermal printing technology and is equipped with 5 rolls of adhesive printing paper & 5 rolls thermal printing paper , ink-free printing, the 2-inch wide thermal paper can be freely cut to length or shape, as well as labels size to create your own sticker ideas anytime, anywhere (Black and White only)
- Bluetooth One-Click Printing APP: The label printer uses the "Tiny Print" app Bluetooth connection, no other complicated processes are required, just follow the connection instructions to quickly connect to the smartphone, the app is equipped with free zoom and drag options, OCR functions and stickers Lots of templates, editing options, and text
- Long Battery Life & 200DPI Resolution: The sticker maker has a built-in high-density rechargeable 1200mAh lithium-ion battery, with 200dpi high-resolution printing imaging to protect children's eyes, note: if the printing is not clear after repeated use, you can use alcohol to wipe the laser bar of the printer (the laser bar is located in the paper loading compartment)
- Compact & Portable Size: Mini thermal printer for phone, elegant, cute appearance, compact and lightweight body size, can be carried in a schoolbag or bag, placed on a desk, office desk, or kitchen without taking up space, you can record study notes or work plans at any time to meet your various printing needs
- Multifunctional Mini Printer: Using the mini sticker printer, you can print black and white photos, pictures, study notes, to-do lists, shopping lists, etc. as well as customize bookmarks, labels, magazines and greeting cards, the APP contains a variety of templates and is compatible with Android 4.0 and IOS9.0 or higher
Create a Playwright screenshot script
Save this file as capture.mjs in the project directory. It accepts an HTML file path or URL and an output image path. Optional arguments select a full-page image or a CSS element. It waits for document fonts and currently loading images before capturing; pages with client-rendered content may need an additional readiness selector, covered below.
import { chromium } from 'playwright';
import { pathToFileURL } from 'node:url';
import path from 'node:path';
const [input, output, mode = 'viewport', selector] = process.argv.slice(2);
if (!input || !output) {
console.error('Usage: node capture.mjs <html-path-or-url> <output.png|jpg|webp> [viewport|full|element] [selector]');
process.exit(2);
}
function toUrl(value) {
if (/^https?:///i.test(value) || value.startsWith('file:')) return value;
return pathToFileURL(path.resolve(value)).href;
}
const type = path.extname(output).toLowerCase().replace('.', '');
if (!['png', 'jpg', 'jpeg', 'webp'].includes(type)) {
throw new Error('Output extension must be png, jpg, jpeg, or webp.');
}
if (mode === 'element' && !selector) {
throw new Error('Element mode requires a CSS selector.');
}
const browser = await chromium.launch({ headless: true });
try {
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
const page = await context.newPage();
const response = await page.goto(toUrl(input), { waitUntil: 'load', timeout: 60000 });
if (response && !response.ok()) {
throw new Error(`Navigation returned HTTP ${response.status()}: ${response.url()}`);
}
await page.evaluate(async () => {
if (document.fonts?.ready) await document.fonts.ready;
await Promise.all([...document.images].map(image => {
if (image.complete) return Promise.resolve();
return new Promise(resolve => {
image.addEventListener('load', resolve, { once: true });
image.addEventListener('error', resolve, { once: true });
});
}));
});
const options = { path: output, type: type === 'jpg' ? 'jpeg' : type };
if (type === 'jpg' || type === 'jpeg') options.quality = 90;
if (mode === 'full') {
options.fullPage = true;
} else if (mode === 'element') {
await page.locator(selector).waitFor({ state: 'visible', timeout: 15000 });
await page.locator(selector).screenshot(options);
console.log(`Saved element ${selector} to ${output}`);
process.exit(0);
} else if (mode !== 'viewport') {
throw new Error(`Unknown mode: ${mode}. Use viewport, full, or element.`);
}
await page.screenshot(options);
console.log(`Saved ${mode} screenshot to ${output}`);
} finally {
await browser.close();
}
The script uses Playwright’s screenshot format setting. PNG is lossless and does not need a quality value; JPEG is lossy, so the example chooses quality 90; WebP is also supported. The file extension and requested type should agree. The example sets a 1440 × 900 CSS-pixel viewport for ordinary captures; change those dimensions in newContext if your report or target layout needs another viewport.
Run it from PowerShell
For a local file, pass its path as the first argument. PowerShell’s call operator runs Node, and $LASTEXITCODE lets a calling script or scheduled task detect failure.
Free tools Windows power users keep installed
One-click scans. No signup required.
$ErrorActionPreference = 'Stop'
$inputHtml = (Resolve-Path '.report.html').Path
$outputImage = Join-Path $PWD 'report.png'
node .capture.mjs $inputHtml $outputImage viewport
if ($LASTEXITCODE -ne 0) {
throw "Screenshot failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path -LiteralPath $outputImage)) {
throw "Capture finished without creating $outputImage"
}
Write-Host "Created $outputImage"
For a URL, provide the URL string instead of the resolved local path:
$url = 'https://example.com/report'
$outputImage = Join-Path $PWD 'page.webp'
node .capture.mjs $url $outputImage full
if ($LASTEXITCODE -ne 0) { throw 'Screenshot failed.' }
Quote paths containing spaces when invoking Node. PowerShell passes each quoted variable as one argument, so a file such as C:ReportsQuarterly report.html does not get split at the space. For repeatable jobs, use absolute paths for the script, input, and output rather than depending on the task scheduler’s working directory.
Rank #2
- User-Friendly Portable Photo Printer for iPhone, Android & PC - Get beautiful and colourful memories with Liene 4x6 photo printer! After opening the entire package, you can find one cartridge + 20 sheets of photo paper (placed inside the machine packaging), as well as an additional box containing 80 sheets of photo paper (which includes two cartridges + 80 sheets of photo paper). Full package includes smartphone photo printer, Liene 4x6 photo printer papers (100 sheets), 3 colour cartridges, and fully sealed cassette to prevent dust. Minimalist and magnetic design for compact storage.
- Superior Quality 4x6 Photo Printer - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Clean the print head promptly if smudges are observed on printed photos during operation. Get Liene photo printers now for yourself and your loved ones, print your happy moments together and keep your love forever!
- Wi-Fi Photo Printer for Smartphone - The built-in hotspot of the photo printer makes it easy to print pictures from your phone, avoiding outside interference with a fast and stable connection. No other networks required! Simply connect your device to the independent instant photo printer 4x6 hotspot.
- Multiple Device Compatibility - Liene phone printer provides instant photo printing for up to 5 simultaneous connections. Share with family and friends or print from your different devices. No additional cables or Bluetooth required when printing photos with this picture printer. Note: Ensure the ink cartridge clicks into place before printing.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Square border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this photo printer for iphone 4x6 prints.
Choose viewport, full-page, or element capture
Viewport
The default captures the visible browser viewport at the configured width and height. Use it when the output should show the initial screen or match a fixed-size preview. Content below the fold is not included.
Full page
Pass full as the third argument to capture the complete scrollable document:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutenode .capture.mjs .report.html .report-full.png full
Long pages can produce very tall images and substantial memory or file-size demands. If the destination system has image-dimension limits, capture sections separately or produce a PDF instead of one exceptionally tall bitmap. Pages that load content only when scrolled may need explicit scrolling or application-specific readiness logic before the screenshot; full-page mode alone does not guarantee that every lazy-loaded item has appeared.
One element
Pass element and a CSS selector to capture only a chart, table, or card. The script waits for the matching element to become visible, then writes its bounds as an image:
node .capture.mjs .report.html .chart.png element '#sales-chart'
The selector must match an element in the rendered page. If it matches nothing, or the element never becomes visible, the wait times out instead of producing a misleading empty capture. Escape or quote selectors that contain characters PowerShell treats specially.
Rank #3
- Dock Photo Printer: The KODAK Dock Plus is a home photo printer that produces high-quality 4x6” prints directly from compatible smartphones. Featuring an integrated docking station, users can place their phone on the printer for better connection while simultaneously charging the device during printing.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Dock Plus is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Home Printing Station: Designed for stable desktop use, this dock photo printer connects to a power outlet for consistent performance and larger 4x6” prints. Ideal for home printing, photo albums, framing, family events, and everyday picture printing.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
Wait for the right page state
Waiting for the browser’s load event is a useful baseline, not a universal definition of “ready.” It does not ensure that a single-page app has finished its data request, that an animation has stopped, or that every lazy image has been requested. The example also waits for font readiness and image load/error events, but each page may need a condition specific to its content.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsFor an app with a known completion marker, add a selector wait after page.goto, before the screenshot. For example:
await page.locator('[data-report-ready="true"]').waitFor({ state: 'visible', timeout: 30000 });
Replace the selector with an element your own page exposes only after rendering is complete. A fixed delay can be used for a short-lived animation or transition, but it is less reliable than waiting for a meaningful state: too short can capture unfinished content, and too long wastes time on every run. Avoid treating “network idle” as a universal signal for modern sites, which may keep analytics, polling, or other connections open.
PowerShell alternative for an occasional manual capture
If you need one screenshot rather than a repeatable script, Microsoft Edge’s built-in Screenshot feature can capture a full webpage or selected area and save or copy the result. That is convenient for an interactive one-off, but it is not a PowerShell automation path: it requires a person to operate the browser UI. For scheduled tasks, CI, or batches of pages, keep the browser workflow in Playwright.
Troubleshoot common failures
- Playwright cannot find Chromium: install the browser binaries in the same environment as the package with
npx playwright install chromium. In a container or CI job, do this during environment setup rather than assuming a developer’s local browser installation is available. - Browser launch reports missing system libraries: the machine may have the Playwright package and browser files but lack OS dependencies. Install the dependencies required for that platform or use an environment image intended for Playwright browsers.
- Navigation times out: check DNS, proxy and firewall access, the URL, and whether the page waits indefinitely on a request. Increase the navigation timeout only when the page legitimately takes longer; do not hide a broken endpoint with an unlimited wait.
- The image is blank or incomplete: check that the input path resolves, that the page has finished its own rendering, and that required assets can load. Add a wait for a page-specific readiness selector, and inspect the page in a headed browser while debugging.
- A local page cannot load its assets: relative paths in HTML resolve relative to the file URL. Keep referenced files in the expected directory structure, or correct the HTML’s asset paths. Remote fonts, scripts, and images still require network access.
- Element capture times out: verify the selector in the final DOM and make sure the target is not hidden, inside an unopened tab, or created only after another action. Wait for the application state that reveals it before the locator wait.
- Edge differs from bundled Chromium or will not launch: confirm the Edge installation and channel available on that machine. Enterprise policies may restrict control of installed branded browsers; test the target environment rather than assuming local success transfers to managed machines.
- PowerShell reports success but no image exists: check the Node exit code, output directory permissions, and the script’s printed path. Keep the explicit output-file check in automation so a missing artifact fails the job.
Performance, reliability, and output considerations
A capture requires starting or reusing a browser process, loading the page, waiting for its content, and encoding the image. There is no universal runtime figure: page complexity, external assets, viewport size, browser startup, and the machine’s resources all affect elapsed time. Avoid adding arbitrary sleeps to every job; wait for the state needed by the page and set finite timeouts so a stalled capture returns control.
Rank #4
- 2x3" Portable Photo Printer: The upgraded PP01 photo printer uses advanced inkjet technology. This portable photo printer produces vivid, full-color prints on premium sticky-backed photo paper that is smudge-proof, water-resistant, and tear-resistant. The Nelko mini photo printer is pocket-sized and weighs only 308g, making it ultra-portable for school, travel, and field trips. Each ink cartridge prints up to 80 full-color 2x3 photos on sticky-backed paper
- Easy Printing via Bluetooth: The PP01 mini photo printer is compatible with iOS and Android phones via Bluetooth. Simply download the Nelko app from Google Play or the App Store. Load the 2x3 photo paper with the smooth side facing down. Install the ink cartridge, connect via Bluetooth, and print directly using the Nelko app. A USB charging cable is included; the adapter is not included
- High Photo Quality: This mini photo printer uses advanced inkjet technology for clear, vibrant prints. This portable photo printer produces 600 DPI high-resolution images with precise colors, capturing fine details and realistic tones. Each photo comes with adhesive backing, perfect for scrapbooks and preserving your memories. Personalize every photo for holidays, birthdays, or daily events
- Powerful App: The Nelko 2x3" PP01 photo printer app lets you edit photos and offers a variety of frame designs, making it perfect for personalizing your photos for projects like scrapbooking or journaling. Download the Nelko app to create collages and customize photos with filters, graffiti, borders, stickers, text, AI image editing, and many other features. Edit photos on your phone, then send them to the Nelko app for instant printing in under 90 seconds
- Versatile Usage Scenarios: This portable photo printer is ideal for travel journals, party favors, and family gatherings. Students use it for planners and photo printing. Crafters use it for DIY projects, custom labels, and scrapbooking. It's a practical tool for bloggers, small businesses, and event photographers to create instant giveaways. Perfect for Mother's Day surprises and heartfelt moments with loved ones using Nelko sticky-backed photo paper.
For a sequence of captures, repeatedly launching Chromium adds startup work. A longer-lived worker can reuse a browser process while creating a fresh page or context for each job, but it must still close pages and handle failures so state, cookies, or memory do not leak between tasks. The self-contained example intentionally opens and closes one browser for clarity and isolation.
For consistent output, keep the browser installation and viewport dimensions stable, use local or reliably reachable assets, and wait for fonts and application content. Screenshots are raster outputs: text and layout are rendered into pixels, so they are not searchable or editable like the original HTML. Large full-page captures can take more memory and storage than viewport captures.
Or skip the browser setup
If you need to capture a public URL without installing or maintaining a local browser, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF. This API example captures the target webpage as WebP; it takes a URL, so it is not a direct replacement for rendering an HTML file that exists only on your computer. See the ScreenshotNeo API documentation for available parameters.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Recommended Free Tools
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can a PowerShell script capture an HTML file without showing a browser window?
Yes. Playwright launches headless by default, so the browser can render the file without a visible window.
Does a screenshot preserve selectable text from the HTML?
No. PNG, JPEG, and WebP screenshots are raster images; the text becomes pixels rather than searchable page text.
Can I use this workflow on a scheduled task or CI agent?
Yes, provided Node.js, the Playwright package, the browser binaries, and any required operating-system dependencies are installed in that execution environment.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

