
How to take screenshots and generate PDFs in C# and .NET
How to Take Screenshots and Generate PDFs in C# and .NET The usual .NET options for screenshots and PDFs are PuppeteerSharp or Playwright for .NET — both download a bundled Chromium binary on first run (~200MB), require a writable filesystem, and don't work in restricted environments like Azure Functions on the Consumption plan or Lambda. Here's the simpler path: HttpClient , System.Text.Json , binary response. No browser download. Screenshot from a URL using System.Net.Http ; using System.Text ; using System.Text.Json ; public class PageBoltClient { private static readonly HttpClient _http = new (); private readonly string _apiKey = Environment . GetEnvironmentVariable ( "PAGEBOLT_API_KEY" )!; private const string BaseUrl = "https://pagebolt.dev/api/v1" ; public async Task < byte [ ]> ScreenshotAsync ( string url ) { var body = JsonSerializer . Serialize ( new { url , fullPage = true , blockBanners = true }); using var request = new HttpRequestMessage ( HttpMethod . Post , $" { BaseUr
Continue reading on Dev.to Webdev
Opens in a new tab



