For a browser-rendered PDF in .NET, use Playwright for .NET: open the page and call Page.PdfAsync. It returns PDF bytes and can also save to a file. By default, PDF generation uses print media, so decide whether you want print styling or screen styling before choosing paper size, margins and background options.
Render a webpage to PDF with Playwright for .NET
Install the Playwright .NET package and its supported browser, then navigate to the page and save the PDF. This example uses Chromium and A4 paper; adjust the browser installation and package setup to match the current Playwright for .NET documentation.
As an Amazon Associate I earn from qualifying purchases.
using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com");
await page.PdfAsync(new PagePdfOptions
{
Path = "page.pdf",
Format = "A4",
PrintBackground = true
});
PdfAsync can save directly using the Path option or return PDF bytes when you need to store or process the result yourself. See the Playwright for .NET Page PDF API for the current API details.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesRender HTML you already have
If the application generates HTML instead of starting with a URL, assign it to the page with SetContentAsync, then create the PDF:
#1 Best Overall
- PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
- QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
- VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
- INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
- EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0
await page.SetContentAsync("<html><body><h1>Invoice</h1></body></html>");
await page.PdfAsync(new PagePdfOptions
{
Path = "invoice.pdf",
Format = "A4",
PrintBackground = true
});
Choose print or screen styling
Playwright generates PDFs using print media by default. A page’s print-specific CSS can therefore change or hide content compared with what a visitor sees in a browser. If the PDF must use screen styles, emulate screen media before calling PdfAsync:
await page.EmulateMediaAsync(new PageEmulateMediaOptions
{
Media = Media.Screen
});
await page.PdfAsync(new PagePdfOptions { Path = "screen-style.pdf" });
Use print media for documents designed for paper, such as pages with print styles or page-break rules. Use screen media when matching the on-screen layout is the requirement. Test pages with both responsive and print CSS rather than assuming the two modes are interchangeable.
Rank #2
- FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
- READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
- WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
- OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)
Set page size, margins and output options
Choose PDF settings deliberately; defaults may not match the document’s intended layout. Playwright documents these relevant options:
Formatselects a standard paper size such asA4orLetter. Alternatively, set explicit width and height with units.Marginsets page margins using CSS-style units.PrintBackgroundis off by default. Set it totrueif background colors or images are part of the intended design.Scaleadjusts output scale from 0.1 to 2.PageRangesselects which pages to include.PreferCSSPageSizelets CSS@pagesizing take priority when enabled. Without it, CSS page sizing does not take precedence over the PDF options.- Tagged output is available as an option; consult the API documentation for its current name and behavior.
For example, to use Letter paper with explicit margins and background graphics:
Rank #3
- STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
- CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
- HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
- FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
- BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer
await page.PdfAsync(new PagePdfOptions
{
Path = "report.pdf",
Format = "Letter",
PrintBackground = true,
Margin = new Margin
{
Top = "0.5in",
Right = "0.5in",
Bottom = "0.5in",
Left = "0.5in"
}
});
If the document’s CSS defines its own page size, set PreferCSSPageSize = true when that CSS should control the output. Consult the API reference for the exact option types in the Playwright version you install.
Make sure content is ready before capture
PDF generation can begin before a page’s asynchronous content, images or fonts are ready. Navigate using an appropriate readiness condition for the page, wait for required content or a known selector, and inspect the result when output is missing or incomplete. For pages using web fonts, PuppeteerSharp’s PDF example recommends waiting for document.fonts.ready; this highlights a font-readiness concern, but the correct wait strategy depends on the page and rendering API.
Rank #4
- IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
- IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
- IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
- Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
When another renderer may fit better
| Option | What the cited documentation establishes | Consider |
|---|---|---|
| Playwright for .NET | Browser automation API with Page.PdfAsync, print-oriented PDF options and HTML content support. API reference |
A browser-driven workflow with explicit control over media, paper size and output settings. |
| PuppeteerSharp | Its NuGet page describes a .NET 8 version and a .NET Standard 2.0 flavor. Its documentation’s PDF example waits for document.fonts.ready. NuGet package · Project documentation |
Check the target frameworks for the exact release and account for page-resource and font readiness. |
| wkhtmltopdf | The project page identifies it as an HTML-to-PDF tool using Qt WebKit. The cited page does not establish its modern CSS compatibility or current maintenance status. Project page | Validate your pages and deployment requirements before choosing it; the available source does not establish comparative fidelity. |
The available documentation does not provide a controlled fidelity or speed comparison among these renderers. Test representative pages—especially complex CSS, fonts, charts and page breaks—before selecting one for a production workload. Commercial .NET PDF SDKs are another category; vendor documentation establishes HTML webpage rendering capability, but verify current framework support, deployment constraints and licensing directly with the vendor.
Troubleshoot common PDF problems
- The PDF looks different from the browser: print media is the default. Use
EmulateMediaAsyncwith screen media if the PDF should follow screen styles, or adjust the print stylesheet. - Background colors or images are missing: enable
PrintBackground. - The page size ignores CSS
@pagerules: enablePreferCSSPageSizeif CSS sizing should take precedence, and check that the page’s print CSS defines the intended size. - Text or images are absent: wait for the required page content and resources before generating the PDF. For web fonts, investigate font readiness; PuppeteerSharp’s example specifically waits for
document.fonts.ready. - Content is clipped or scaled unexpectedly: verify the selected paper format, explicit dimensions, margins and scale together. Check page-break behavior in print CSS.
Or skip the browser setup
If your .NET application needs a screenshot or PDF from a URL without managing a browser yourself, ScreenshotNeo offers a one-request API. A GET request to its API returns an image or PDF; for example, save a PDF response as a file:
Best Value
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -d format=pdf -o page.pdf
ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers say the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
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.




