Blog
Screenshot rendering
min read

How to take website screenshots with C#/.NET

Learn how to capture website screenshots in C# using PuppeteerSharp locally or Screenshot API as a service, with complete working examples and pros & cons

Capturing website screenshots is a common requirement in modern web development, whether for automated testing, archiving, generating previews, or building reporting tools. In the .NET ecosystem, there are two major approaches to solving this: using a headless browser library like PuppeteerSharp, or calling an external screenshot API as a service.

Each has its own strengths and trade-offs. In this guide, we’ll walk through both options, with working code examples you can run immediately. We’ll also take a moment to compare the pros and cons of each so you can choose the right tool for your use case.

PuppeteerSharp for C#

PuppeteerSharp is a .NET port of the popular Node.js library Puppeteer. It provides a comprehensive API for controlling headless Chrome or Chromium browsers directly from C# code. This allows developers to programmatically navigate to websites, interact with DOM elements, take screenshots, generate PDFs, and run browser-based automation.

Originally inspired by Google’s work on the DevTools Protocol, PuppeteerSharp emerged to fill the gap for .NET developers who wanted the power of headless browsers without leaving the .NET ecosystem. It’s fully async, production-ready, and well-maintained by the open-source community.

To use PuppeteerSharp, add the NuGet package to your project:


dotnet add package PuppeteerSharp

You’ll also need to download the Chromium revision that PuppeteerSharp expects to work with:


await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
C# Code Example with PuppeteerSharp

using System;
using System.IO;
using System.Threading.Tasks;
using PuppeteerSharp;

class Program
{
  public static async Task Main()
  {
    var browserFetcher = new BrowserFetcher();
    await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);

    using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
    {
      Headless = true
    });

    using var page = await browser.NewPageAsync();
    await page.GoToAsync("https://example.com");

    var filePath = Path.Combine(Directory.GetCurrentDirectory(), "puppeteer_screenshot.png");
    await page.ScreenshotAsync(filePath);

    Console.WriteLine($"Screenshot saved to: {filePath}");
  }
}

Pros and cons of PuppeteerSharp

PuppeteerSharp gives you full control over the browsing context: you can click buttons, scroll dynamically, wait for JavaScript to load, or capture only a specific part of the DOM. It’s a powerful choice when your screenshot logic depends on deep browser interactions. But it comes at a cost, you must manage Chromium binaries, deal with possible version mismatches, and ensure the environment where your .NET code runs (especially on CI/CD or cloud) has the resources and permissions to launch a headless browser. Local rendering also tends to consume more memory and CPU over time.

Screenshot API as a Service

ScreenshotMax is a cloud-based API that allows developers to capture screenshots of web pages simply by making HTTP requests. Unlike headless browser libraries, it doesn’t require installing or running any browsers on your machine. All the rendering is done server-side, in the cloud, using a fleet of optimized headless browsers.

ScreenshotMAX was created for developers who value speed, simplicity, and reliability over configuration complexity. With consistent rendering environments and infrastructure that scales, ScreenshotMAX is especially well-suited for SaaS builders, data collection platforms, or anyone needing to generate visual content on-demand from URLs.

C# example code

No SDK is needed to get started, just send an HTTP GET request with the right parameters.


using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
  private static readonly HttpClient client = new HttpClient();

  public static async Task Main()
  {
    string apiKey = "YOUR_ACCESS_KEY";
    string urlToCapture = "https://screenshotmax.com";
    string requestUrl = $"https://api.screenshotmax.com/v1/screenshot?url={Uri.EscapeDataString(urlToCapture)}&full_page=true&access_key={apiKey}";

    var response = await client.GetAsync(requestUrl);
    response.EnsureSuccessStatusCode();

    var imageBytes = await response.Content.ReadAsByteArrayAsync();
    var filePath = Path.Combine(Directory.GetCurrentDirectory(), "screenshotmax_api.png");
    await File.WriteAllBytesAsync(filePath, imageBytes);

    Console.WriteLine($"Screenshot saved via ScreenshotMAX API: {filePath}");
  }
}

Pros and cons of using Screenshot API

The biggest advantage of using a screenshot API is simplicity. There’s no browser to install, no environment configuration to manage, and no risk of breaking due to Chromium updates. It’s fast, secure, and scales easily, ideal for background jobs, scheduled snapshots, or real-time image generation. On the downside, it’s less customizable than running a browser locally. You can’t manipulate the DOM unless the API explicitly supports it. You also need an internet connection and an active API key, and it may come with usage limits depending on your pricing plan.

Conclusion

Both PuppeteerSharp and ScreenshotMAX are capable tools, but serve different needs.

If you need to automate complex browser interactions or generate screenshots in tightly controlled environments, PuppeteerSharp offers fine-grained control. It’s ideal for one-off screenshots, local development, or workflows where you need to manipulate the DOM or wait for dynamic content.

However, if your goal is to capture hundreds or thousands of screenshots reliably, especially in a production setting, a screenshot API like ScreenshotMax is a better choice. It handles the infrastructure, parallel processing, and scaling for you, so you don’t have to worry about memory limits, browser crashes, or queueing jobs manually. You just call the API and get your result back quickly, with consistent rendering and high availability. It’s purpose-built for bulk screenshot tasks and large workloads.

If you want full control of the browser and are comfortable managing infrastructure, PuppeteerSharp is the right choice. You get maximum flexibility and can fine-tune every interaction.

If you need fast, scalable screenshots with zero setup, ScreenshotMAX is a better fit. You trade some control for simplicity, but gain operational efficiency and speed.

Whichever path you choose, C# and .NET give you all the tools you need to build robust, modern screenshot workflows.

Published on

Read more screenshot rendering

Get practical tips, detailed guides, trusted best practices and updates.

Start now

Take website screenshots in minutes
No browser setup, no headaches, no scaling concerns

Complete API for rendering website screenshots, HTML to PDF, animated screenshots, web page scraping, and scheduled screenshots.

No credit card required