DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › AI agents

How to Use an AI Agent to Screenshot a Webpage with a Print Stylesheet

By Freedom251 Team · · 6 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Have the agent open the page in a browser automation runtime, wait for the content you need, switch the page to print media, then capture it with a screenshot operation. In Playwright, use page.emulateMedia({ media: 'print' }) before page.screenshot(). Choose a full-page image, viewport, or element capture according to what you need. If you need a paginated document rather than an image, use page.pdf() instead.

What print media changes—and what it does not

A site may define print-specific presentation with @media print rules in its stylesheet or with a stylesheet linked using media="print". Emulating print media tells the browser to apply those rules while rendering the page. Rules can hide navigation or controls, change typography, or alter layout, depending on what the site has authored.

As an Amazon Associate I earn from qualifying purchases.

Print media emulation does not itself create a print stylesheet, guarantee a clean result, or paginate a screenshot. It only changes the media type used for rendering. Inspect the result for clipped content, unwanted controls, missing images, and other layout changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose an image or a paginated PDF

Need Playwright operation What to expect
A visual image of the rendered page page.screenshot() A raster capture of the viewport, a selected element, or the full scrollable page. A full-page image can be very tall; it is not a paginated print document.
A document laid out across pages page.pdf() A PDF with print media applied by default and pagination. Inspect it when page dimensions, margins, or page breaks matter.

Playwright’s PDF operation uses print CSS media by default. If you want a PDF in screen styling, call page.emulateMedia({ media: 'screen' }) before page.pdf(). For a screenshot, set the media explicitly so the capture uses the styling you intend.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Capture a print-styled screenshot with Playwright

This JavaScript example uses Playwright’s library API. Install Playwright and its browser runtime in your project first, then save the script as print-shot.mjs. It accepts a URL as its first command-line argument, waits for the page’s load event, emulates print media, and saves a full-page PNG. Adapt the readiness condition for pages that render important content after navigation.

import { chromium } from 'playwright';

const url = process.argv[2];
if (!url) {
  throw new Error('Usage: node print-shot.mjs https://example.com');
}

const browser = await chromium.launch();
try {
  const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
  await page.goto(url, { waitUntil: 'load', timeout: 60000 });

  // Replace with a page-specific selector if key content loads asynchronously.
  await page.emulateMedia({ media: 'print' });
  await page.screenshot({ path: 'page-print.png', fullPage: true, type: 'png' });
} finally {
  await browser.close();
}
  1. Pass the page URL: run node print-shot.mjs https://example.com, replacing the example with the page you are authorized to capture.
  2. Wait for the right content: the example waits for the browser’s load event. For a dynamic page, add a page-specific wait such as await page.locator('main article').waitFor({ state: 'visible' }); before changing media or capturing. Use a selector that identifies the content you need, not one copied blindly from the example.
  3. Emulate print before the screenshot: page.emulateMedia({ media: 'print' }) changes the rendering media. The order matters: do this before capturing the image.
  4. Pick the capture extent: keep fullPage: true for the full scrollable page. Remove it to capture the viewport. To capture one element, call page.locator('main article').screenshot({ path: 'article-print.png' }) after replacing the selector with the target element.
  5. Review the output: open page-print.png and check content, layout, and images. A screenshot shows one continuous rendered image; use PDF generation if you need page breaks and paper dimensions.

Wait for readiness without guessing

A generic delay can help when a known animation or delayed update is involved, but elapsed time alone does not prove that a page is ready. Prefer a selector that appears when the relevant content is present. If the page’s content is not represented by a stable selector, wait for the site-specific event or state that indicates it is ready, then inspect the screenshot.

Choose screenshot extent and image format

Playwright screenshots can capture the viewport, a selected element, or the full scrollable page. PNG, JPEG, and WebP are available screenshot formats. PNG is a straightforward choice for a crisp visual reference; select another supported format when its file characteristics suit your downstream use. A full-page capture can be unusually tall, so use a viewport or element capture when only a portion is relevant.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Choose screenshot scale

Playwright supports CSS-pixel scale and device-pixel scale for screenshots. CSS-pixel scale keeps output dimensions aligned with the page’s CSS layout; device-pixel scale produces a higher-resolution image. Choose based on whether compact dimensions or additional image detail matters for the destination.

Use print CSS deliberately

If you control the page, put print-specific rules in a stylesheet, for example:

@media print {
  nav,
  .controls {
    display: none;
  }

  main {
    max-width: 100%;
  }
}

You can also link a dedicated stylesheet with media="print". CSS specificity and precedence still apply, so inspect the rendered result rather than assuming a rule has taken effect. Typical print styling removes nonessential navigation and controls, preserves a legible reading column, and avoids clipping content.

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Use @page rules when page dimensions, orientation, or margins matter to a printed or PDF output. Support for some paged-media details varies between browsers; check the browser used for the capture when those details are important. These page-layout concerns apply especially to PDFs, not to the pagination of a full-page screenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate a PDF when page breaks matter

For a paginated output, use the separate PDF operation. Playwright applies print media by default when generating a PDF:

await page.pdf({ path: 'page-print.pdf' });

Call this after navigating to the page and waiting for its content. You can make the intended media state explicit with await page.emulateMedia({ media: 'print' }); before the PDF call. If you deliberately want screen styling in the PDF, set screen media before generating it. Inspect the resulting PDF for page breaks, margins, and missing or clipped content.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Keep the agent’s browser state intentional

Media emulation changes the page’s rendering state. If the agent continues working with the same page after capture, set the intended media explicitly—for example, call page.emulateMedia({ media: 'screen' }) before returning to screen-oriented interactions. Do not assume a later task should inherit the print view.

Troubleshoot common capture problems

  • The image looks like the screen layout: ensure page.emulateMedia({ media: 'print' }) runs before page.screenshot(). Check that the site’s print rules apply to the content you are viewing.
  • Content is missing: navigation’s load event may occur before client-rendered content is ready. Wait for a page-specific selector or readiness state before taking the screenshot.
  • The full-page image is unexpectedly long: full-page capture includes the page’s scrollable content. Capture the viewport or a target element if that is the intended scope.
  • The image has no page breaks: that is expected for a screenshot. Use page.pdf() when you need a paginated document.
  • PDF styling differs from the screenshot: screenshots and PDFs are separate outputs with different capture behavior. Set the desired media state explicitly, then inspect the specific output you plan to use.
  • A print rule seems ignored: check that the stylesheet is loaded, that its media condition matches, and that another rule with greater specificity or precedence is not overriding it.
  • Page dimensions or margins differ from expectations: check the @page rules and validate the result in the browser used for capture; support for some paged-media details varies.
  • Navigation times out: confirm the URL is reachable from the machine running the browser and choose a timeout appropriate to the target. A longer timeout does not replace a meaningful content-readiness check.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a standard hosted webpage screenshot, ScreenshotNeo offers a one-request API. Its documented call does not expose a print-media emulation option, so use the Playwright workflow above when the page’s print stylesheet specifically must be applied.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL example and ScreenshotNeo API documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. It also has an MCP server with screenshot, page-info, and PDF tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Frequently asked questions

Can an AI agent use its own browser tool instead of a Playwright script?

Yes, if that browser tool lets the agent control the page’s media emulation and capture operations. The essential sequence is to load the target page, wait for the relevant content, set print media, and take an image capture.

Does a screenshot include a page’s print stylesheet automatically?

Not necessarily. Explicitly request print media in the browser before taking the screenshot; do not assume an image capture uses the same media behavior as PDF generation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

AI agentsbrowser automationPlaywrightPrint CSSWebpage screenshots

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.