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

Use Playwright for .NET to render HTML in a browser and capture the page as a PNG. Set the page content, wait for any content your image depends on, then call Page.ScreenshotAsync. This is browser-based rendering—not a built-in .NET HTML-to-image encoder—and it can save a PNG file or return image bytes.

Convert HTML to a PNG file

Install the Playwright for .NET package in your project, install the matching browser binaries for your environment, and use the following asynchronous method. The example writes output.png to the application’s current working directory.

using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();

await page.SetContentAsync("<html><body><h1>Hello</h1></body></html>");
await page.ScreenshotAsync(new() { Path = "output.png" });

The sample shows the documented API shape; it has not been executed here. For a real project, add explicit readiness handling when the desired image depends on external resources or asynchronous page work. Browser installation and deployment requirements are part of the implementation, not something that the package reference alone guarantees.

Save the screenshot bytes instead of a file

If the next step in your application needs a byte array—for example, to pass the image to another method—omit Path and use the returned buffer:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
var pngBytes = await page.ScreenshotAsync();

PNG is the screenshot API’s default output type. The returned bytes can be stored or passed to code that accepts image data. For file output, provide a path as in the first example.

Supply markup or navigate to a page

Use SetContentAsync when you already have the HTML markup you want rendered. If the content is hosted at a URL, navigate the page to that URL instead:

await page.GotoAsync("https://example.com");
await page.ScreenshotAsync(new() { Path = "page.png" });

These approaches still render through a browser page. The right choice depends on where the content lives: direct markup is convenient for generated HTML, while navigation lets the browser load a hosted page and its related resources.

Wait for the page state you actually need

A screenshot captures what the browser has rendered at capture time. A successful call does not, by itself, mean that every image, font, script, or application-driven update has finished. Decide what “ready” means for your particular page, then wait for that condition before taking the screenshot.

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

Wait for a page-specific element

If the image should include a particular component, wait for its selector to appear or reach the required state before capturing. For example, a page might first render a loading shell and later insert a report; capturing immediately after navigation can preserve the shell instead of the report.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Allow for external resources and asynchronous rendering

Pages that use external images, web fonts, scripts, or client-side rendering may need additional readiness checks. There is no single wait strategy that is correct for every page. Choose a condition that corresponds to the content you need, and verify that it also handles the page’s slow or failed-resource cases.

Choose full-page or element-only capture

By default, a screenshot represents the current visible page area. Use the full-page option when the output should include the scrollable document as one tall image. Use a locator screenshot when the target is a specific component rather than the entire page.

// Capture the full scrollable page.
await page.ScreenshotAsync(new() {
    Path = "full-page.png",
    FullPage = true
});

// Capture only the element matched by a selector.
await page.Locator(".report-card").ScreenshotAsync(new() {
    Path = "report-card.png"
});

Full-page output can be much taller than the browser viewport. Element capture is useful when surrounding navigation or page content should not appear in the PNG. Select the scope that matches the image you intend to produce rather than capturing a larger page and cropping it later.

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

Control output and layout

The screenshot API provides options for full-page capture, element capture, scale, and timeout. The page’s viewport and layout also affect the screenshot’s dimensions and what responsive content is shown. Set the viewport deliberately when the PNG must represent a particular layout; use the screenshot scale option when you need to control the output scale.

PNG does not use a quality setting in this API. If dimensions matter, decide both the page layout and the desired capture scope before saving. Changing the viewport can cause responsive HTML to render differently, not merely resize the same finished image.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Install and deploy the browser runtime

Playwright for .NET supports Chromium, Firefox, and WebKit, as well as branded Chrome and Edge channels. For a reproducible deployment, use the browser and runtime setup documented for the Playwright package version and operating system you choose. Browser binaries and, in some environments, system dependencies need to be installed separately; referencing the .NET package does not establish that a browser is present.

  1. Add Playwright for .NET to the project and pin or otherwise control the package version as appropriate for your application.
  2. Install the corresponding browser binaries using the Playwright installation instructions for that package and target environment.
  3. Check OS dependencies and packaging on the deployment machine, especially if the application runs in a container or on a server rather than a developer workstation.
  4. Run a capture in the target environment and confirm that launch, page rendering, resource loading, and file or byte output work there.

Keep the package, browser binaries, and deployment environment aligned. Installation steps and available browser versions can change, so consult the official Playwright .NET setup and release documentation for your selected version rather than assuming a browser installed on one machine will be available on another.

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

When WebView2 may fit a Windows application

If your Windows application already hosts web content in Microsoft Edge, WebView2 may be a relevant rendering host. Microsoft lists .NET/C#, WPF, and Windows Forms among the supported frameworks, and describes WebView2 as hosting Chromium-based Edge content. Playwright also documents connecting to a WebView2 instance using CDP.

That makes WebView2 an integration option when the application already uses it; it is not a one-line substitute for the Playwright screenshot example above. The sources cited here do not provide a complete standalone WebView2-to-PNG recipe. Verify the capture path for the specific application and integration you plan to use.

Or skip the browser setup

If you need a screenshot through an API rather than rendering it inside your .NET process, ScreenshotNeo accepts a URL and returns an image or PDF. The call below saves a PNG response for a URL; see the ScreenshotNeo API documentation for the request options and response details.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.png
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture by default; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. The response includes X-Page-Verdict and X-Billed headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.

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

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common capture problems

The browser fails to launch

Check that the required Playwright browser binaries are installed for the package version and that the target operating system has the necessary dependencies. A package reference does not install every runtime component needed on every deployment host. Compare the failing environment with the official setup instructions for that version and OS.

The PNG is blank or missing content

Check that the page received the intended markup or URL, then wait for the specific content the image needs before capturing. If content comes from a script, external image, or font, confirm that it loads in the target environment and that your readiness condition covers the relevant update.

The image has the wrong dimensions or layout

Check whether you intended a viewport screenshot, a full-page image, or an element-only capture. Then inspect the viewport and scale settings. A different viewport may also select a different responsive layout, so verify the rendered page as well as the resulting pixel dimensions.

The capture takes too long

Use a timeout appropriate to the page and environment, and avoid waiting for a condition that the page may never satisfy. For example, a page-specific element can be a more relevant readiness target than an overly broad wait when unrelated activity continues in the background. The right condition depends on the page; no universal timing or performance guarantee is established here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Performance, reliability, and cost considerations

Browser capture requires launching or reusing a browser runtime and rendering the page, so account for that work in your application’s runtime and deployment design. The cited API and setup documentation does not establish a universal speed comparison between Playwright and WebView2, or guarantee identical rendering across every operating system and deployment. Test the pages and environment that matter to your application.

For reliability, make content readiness explicit, handle the possibility that a resource or page condition fails, and validate output in the target environment. The cited material does not provide a general .NET conversion cost or benchmark figure. Your operational cost depends on your hosting and implementation choices; no numeric estimate is established here.

Frequently Asked Questions

Does Playwright for .NET convert HTML without a browser?

No. The documented screenshot workflow renders a browser page and captures it; it is not a built-in .NET HTML image encoder.

Can I save a screenshot without writing it to disk first?

Yes. Call `ScreenshotAsync` without a `Path` and use the returned byte buffer.

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

Which browser should I use?

Playwright documents Chromium, Firefox, and WebKit, plus branded Chrome and Edge channels. Choose and install the browser runtime supported by your application’s target environment.

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.