Convert HTML to PDF in C# and ASP.NET Core
Free and paid ways to turn HTML into PDF in .NET, checked in November 2026: PuppeteerSharp and Playwright for .NET (free Chromium), QuestPDF when you don't need HTML, what happened to DinkToPdf, the verified licensing terms of IronPDF, Syncfusion and iText, and an ASP.NET Core endpoint that renders a Razor component to PDF.
Last updated
Short answer
The best free option is PuppeteerSharp (MIT): await page.SetContentAsync(html), then await page.PdfAsync("out.pdf", new PdfOptions { Format = PaperFormat.A4, PrintBackground = true }). It prints with real Chrome, so modern CSS renders correctly. Playwright for .NET works the same way. If you don't need HTML, QuestPDF builds PDFs in C#. Avoid DinkToPdf: wkhtmltopdf is archived.
Most .NET HTML-to-PDF advice online is either a vendor page selling one library or a tutorial built on wkhtmltopdf, which stopped being maintained years ago. The useful split is this: Chromium drivers (PuppeteerSharp, Playwright) are free and render HTML exactly as Chrome does, but you run a browser process. Commercial converters (IronPDF, Syncfusion, iText pdfHTML) wrap an engine in a .NET API and charge for most commercial use. Code-first libraries (QuestPDF) skip HTML entirely. Package versions below come from NuGet, and licensing terms from each vendor's own site, all checked on November 27, 2026.
C# HTML-to-PDF libraries compared
| Library | Renders HTML? | Engine | License and price (Nov 2026) | Latest release |
|---|---|---|---|---|
| PuppeteerSharp | Yes: HTML string or URL | Chrome, downloaded by BrowserFetcher | MIT, free | 25.18.1, Nov 2026 |
| Microsoft.Playwright | Yes: HTML string or URL | Chromium (PDF is Chromium-only) | MIT (per NuGet), free | 1.65.1, Nov 2026 |
| QuestPDF | No: fluent C# layout API | Its own engine; no HTML, CSS or JS | Free Community license under USD 1M annual revenue; Professional $1,999, Enterprise $4,999 | 2026.9.2, Nov 2026 |
| IronPDF | Yes | Chromium | Commercial; perpetual licenses from $999 (Lite); 30-day trial | 2026.11.1, Oct 2026 |
| Syncfusion HTML to PDF | Yes | Blink (Chromium) | Commercial; free Community License for small companies | Commercial product |
| iText pdfHTML | Yes, static HTML and CSS | iText's own HTML-to-PDF mapping, not a browser | AGPL or commercial | 6.3.4, Sep 2026 |
| DinkToPdf | Yes | wkhtmltopdf (QtWebKit) | MIT, free | 1.0.8, April 2017; engine archived |
| RenderKit API | Yes: HTML string or URL | Hosted Chromium | 500 free credits, then from $9/month | Hosted service |
Which one should you use?
- You want a free C# HTML-to-PDF library with modern CSS → PuppeteerSharp. MIT-licensed, prints through Chrome, and its API mirrors Node's Puppeteer, so most Puppeteer answers translate directly.
- Your team already uses Playwright for end-to-end tests → Playwright for .NET. Same engine, official Docker images, and one fewer dependency.
- You're generating invoices, reports or labels from data and HTML is optional → QuestPDF. No browser, fast, and a strong layout API, but check whether your company qualifies for the free Community license.
- You need a supported commercial product and a vendor to call → IronPDF or Syncfusion (both Chromium-based), or iText if you're already in its ecosystem. Read the licensing section first.
- You're on DinkToPdf or another wkhtmltopdf wrapper → plan a migration. The engine is archived and its maintainers warn against untrusted HTML.
- You can't run Chromium where your app runs (locked-down hosting, small containers) → call Gotenberg or a hosted API with
HttpClient.
PuppeteerSharp: free HTML to PDF in C#
PuppeteerSharp is a .NET port of Puppeteer. It drives Chrome over the DevTools Protocol, and BrowserFetcher downloads a matching Chrome build the first time it runs, so there's nothing else to install on a developer machine.
dotnet add package PuppeteerSharpusing PuppeteerSharp;
using PuppeteerSharp.Media;
// Downloads a Chrome build on first run; later runs reuse it
await new BrowserFetcher().DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
await using var page = await browser.NewPageAsync();
var html = """
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: system-ui, sans-serif; font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px; border-bottom: 1px solid #ddd; text-align: left; }
thead { background: #f3f4f6; }
</style>
</head>
<body>
<h1>Invoice INV-1024</h1>
<table>
<thead><tr><th>Item</th><th>Amount</th></tr></thead>
<tbody><tr><td>Pro plan, November</td><td>$29.00</td></tr></tbody>
</table>
</body>
</html>
""";
await page.SetContentAsync(html); // waits for the load event
await page.EvaluateExpressionHandleAsync("document.fonts.ready"); // web fonts in place
await page.PdfAsync("invoice.pdf", new PdfOptions
{
Format = PaperFormat.A4,
PrintBackground = true, // off by default, which drops background colors
MarginOptions = new MarginOptions { Top = "20mm", Right = "15mm", Bottom = "20mm", Left = "15mm" },
});
// Or keep it in memory
byte[] pdf = await page.PdfDataAsync(new PdfOptions { Format = PaperFormat.A4, PrintBackground = true });Two details matter. First, PrintBackground defaults to false, so table stripes and colored headers disappear unless you turn it on. Second, wait for fonts: the PuppeteerSharp README notes that skipping document.fonts.ready can leave text missing from the PDF. SetContentAsync waits for the load event by default, and it doesn't support the Networkidle0 and Networkidle2 conditions. For a live URL, those conditions work with GoToAsync:
// A live URL instead of an HTML string
await page.GoToAsync("https://example.com/reports/q3", WaitUntilNavigation.Networkidle0);
await page.WaitForSelectorAsync("#revenue-chart svg"); // content a script draws late
await page.PdfAsync("q3.pdf", new PdfOptions { Format = PaperFormat.A4, PrintBackground = true });Headers, footers and page numbers
Set DisplayHeaderFooter and pass HTML templates. Chrome fills elements with the classes pageNumber, totalPages, date, title and url. Templates don't see your page's stylesheet, so style them inline and give them an explicit font size:
byte[] pdf = await page.PdfDataAsync(new PdfOptions
{
Format = PaperFormat.A4,
PrintBackground = true,
DisplayHeaderFooter = true,
HeaderTemplate = "<span></span>", // empty, so Chrome's default header isn't printed
FooterTemplate =
"<div style='font-size:9px; width:100%; text-align:center; color:#666;'>" +
"Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>",
// The footer prints inside the bottom margin, so leave room for it
MarginOptions = new MarginOptions { Top = "15mm", Right = "15mm", Bottom = "20mm", Left = "15mm" },
});Playwright for .NET
Microsoft's Playwright has an official .NET package. Browsers are installed by a PowerShell script generated in your build output, which needs pwsh available, including on Linux build agents:
dotnet add package Microsoft.Playwright
dotnet build
pwsh bin/Debug/net8.0/playwright.ps1 install chromium # use your target framework folderusing Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
// html: your document as a string, as in the PuppeteerSharp example
await page.SetContentAsync(html, new() { WaitUntil = WaitUntilState.Load });
// or: await page.GotoAsync("https://example.com/report", new() { WaitUntil = WaitUntilState.NetworkIdle });
byte[] pdf = await page.PdfAsync(new()
{
Path = "report.pdf", // optional; the bytes are returned either way
Format = "A4", // default: Letter
PrintBackground = true, // default: false
Margin = new() { Top = "20mm", Right = "15mm", Bottom = "20mm", Left = "15mm" },
});PdfAsync only works in Chromium, and its defaults match Puppeteer's: Letter paper, no backgrounds. Header and footer templates use the same classes, with the same limits: scripts inside templates don't run, and page styles aren't visible to them. To print with screen styles instead of @media print, call page.EmulateMediaAsync(new() { Media = Media.Screen }) first. The Playwright PDF guide covers waits and pagination in more depth.
ASP.NET Core: generate a PDF from HTML (Razor) in an endpoint
This is the pattern behind "asp.net core generate pdf from html". Write the document as a Razor component, render it to an HTML string with HtmlRenderer (built into ASP.NET Core since .NET 8, no MVC view engine plumbing required), and print it with one long-lived browser. First, a singleton that owns Chromium:
// PdfRenderer.cs: one Chromium for the app's lifetime, a fresh page per document
using PuppeteerSharp;
using PuppeteerSharp.Media;
public sealed class PdfRenderer : IAsyncDisposable
{
private readonly Lazy<Task<IBrowser>> _browser = new(async () =>
{
await new BrowserFetcher().DownloadAsync();
return await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
});
public async Task<byte[]> RenderAsync(string html)
{
var browser = await _browser.Value;
await using var page = await browser.NewPageAsync();
await page.SetContentAsync(html);
await page.EvaluateExpressionHandleAsync("document.fonts.ready");
return await page.PdfDataAsync(new PdfOptions
{
Format = PaperFormat.A4,
PrintBackground = true,
MarginOptions = new MarginOptions { Top = "18mm", Right = "14mm", Bottom = "18mm", Left = "14mm" },
});
}
public async ValueTask DisposeAsync()
{
if (_browser.IsValueCreated) await (await _browser.Value).DisposeAsync();
}
}The document itself is a normal Razor component with a full HTML page in it:
@* Components/InvoiceDocument.razor *@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: system-ui, sans-serif; font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 6px; border-bottom: 1px solid #ddd; text-align: left; }
tr { break-inside: avoid; }
@@media print { a { color: inherit; } }
</style>
</head>
<body>
<h1>Invoice @Invoice.Number</h1>
<table>
<thead><tr><th>Item</th><th>Amount</th></tr></thead>
<tbody>
@foreach (var line in Invoice.Lines)
{
<tr><td>@line.Description</td><td>@line.Amount.ToString("C")</td></tr>
}
</tbody>
</table>
</body>
</html>
@code {
[Parameter, EditorRequired] public Invoice Invoice { get; set; } = default!;
}And the endpoint renders the component, prints it, and returns the file:
// Program.cs (ASP.NET Core, .NET 8 or later)
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<PdfRenderer>();
var app = builder.Build();
app.MapGet("/invoices/{id:int}/pdf", async (int id, HttpContext http, ILoggerFactory loggerFactory, PdfRenderer pdf) =>
{
var invoice = await LoadInvoiceAsync(id); // your data access
// 1. Razor component -> HTML string
await using var htmlRenderer = new HtmlRenderer(http.RequestServices, loggerFactory);
var html = await htmlRenderer.Dispatcher.InvokeAsync(async () =>
{
var parameters = ParameterView.FromDictionary(new Dictionary<string, object?>
{
[nameof(InvoiceDocument.Invoice)] = invoice,
});
var output = await htmlRenderer.RenderComponentAsync<InvoiceDocument>(parameters);
return output.ToHtmlString();
});
// 2. HTML string -> PDF bytes -> file response
var bytes = await pdf.RenderAsync(html);
return Results.File(bytes, "application/pdf", $"invoice-{id}.pdf");
});
app.Run();LoadInvoiceAsyncand theInvoicetype stand in for your own code. Microsoft's docs require everyRenderComponentAsynccall to run insideDispatcher.InvokeAsync, as shown.- Inside a
.razorfile, CSS at-rules need a doubled@: write@@mediaand@@page, or Razor treats them as code. - Launching Chrome is slow; opening a page is fast. That's why the browser is a singleton and each request gets its own page, disposed with
await usingeven when rendering throws. - Keep long or bursty jobs off the request thread: queue them (a background service, Hangfire, a message queue) and store the result, so a spike of PDF requests can't exhaust memory.
QuestPDF: when you don't need HTML at all
QuestPDF describes itself as a code-first PDF library with "no HTML, CSS or JS engines involved". You compose pages with a fluent C# API (rows, columns, tables, images and text) and content flows onto new pages as needed. There's no browser to install, which makes it fast and easy to deploy:
// dotnet add package QuestPDF
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
QuestPDF.Settings.License = LicenseType.Community; // only if you qualify; see below
byte[] pdf = Document.Create(container =>
{
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.DefaultTextStyle(x => x.FontSize(11));
page.Header().Text("Invoice INV-1024").SemiBold().FontSize(20);
page.Content().PaddingVertical(10).Table(table =>
{
table.ColumnsDefinition(columns =>
{
columns.RelativeColumn();
columns.ConstantColumn(80);
});
table.Header(header =>
{
header.Cell().BorderBottom(1).Padding(4).Text("Item").SemiBold();
header.Cell().BorderBottom(1).Padding(4).AlignRight().Text("Amount").SemiBold();
});
table.Cell().Padding(4).Text("Pro plan, November");
table.Cell().Padding(4).AlignRight().Text("$29.00");
});
page.Footer().AlignCenter().Text(text =>
{
text.Span("Page ");
text.CurrentPageNumber();
text.Span(" of ");
text.TotalPages();
});
});
}).GeneratePdf(); // or .GeneratePdf("invoice.pdf")The license is the part to read carefully. Per questpdf.com in November 2026, the free Community license covers individuals and companies with annual gross revenue under USD 1,000,000, plus qualifying non-profits, academic institutions and eligible open-source projects. Public-sector entities and publicly traded companies aren't eligible regardless of revenue. Above that, the Professional license is listed at $1,999 and Enterprise at $4,999. The library needs no license key; you declare your tier with QuestPDF.Settings.License. QuestPDF returns the PDF as a byte[] from GeneratePdf(), so in ASP.NET Core it's Results.File(pdf, "application/pdf").
Convert HTML to PDF in C# without a library
If you can't add a NuGet package, you still need a browser engine somewhere. Two ways to reach one with nothing but the base class library:
Shell out to headless Chrome
Chrome can print a page to PDF from the command line with --headless --print-to-pdf. You lose header templates and wait conditions, but for static HTML on a machine that already has Chrome it works:
using System.Diagnostics;
static async Task<byte[]> HtmlToPdfAsync(string html, string chromePath)
{
var dir = Directory.CreateTempSubdirectory("pdf-");
try
{
var input = Path.Combine(dir.FullName, "input.html");
var output = Path.Combine(dir.FullName, "output.pdf");
await File.WriteAllTextAsync(input, html);
var startInfo = new ProcessStartInfo(chromePath)
{
ArgumentList =
{
"--headless",
"--no-pdf-header-footer",
$"--user-data-dir={Path.Combine(dir.FullName, "profile")}", // don't join a running Chrome
$"--print-to-pdf={output}",
new Uri(input).AbsoluteUri, // file:///...
},
UseShellExecute = false,
};
using var process = Process.Start(startInfo)!;
await process.WaitForExitAsync();
return await File.ReadAllBytesAsync(output);
}
finally
{
dir.Delete(recursive: true);
}
}--no-pdf-header-footer removes Chrome's default date, title and URL lines. The separate --user-data-dir stops Chrome from handing the job to a Chrome window that's already open. In our test on Windows, chrome.exe exited before the PDF was on disk, so on Windows wait for the output file to appear (or use PuppeteerSharp there).
POST the HTML to a rendering service
Gotenberg is an open-source Docker image that exposes Chromium as an HTTP API, and a hosted API (covered at the end of this page) works the same way. Either way your .NET code is plain HttpClient:
// Gotenberg (docker run --rm -p "3000:3000" gotenberg/gotenberg:9) over plain HttpClient
using System.Text;
using var form = new MultipartFormDataContent();
form.Add(new StringContent(html, Encoding.UTF8, "text/html"), "files", "index.html");
form.Add(new StringContent("true"), "printBackground");
using var http = new HttpClient();
using var response = await http.PostAsync("http://localhost:3000/forms/chromium/convert/html", form);
response.EnsureSuccessStatusCode();
byte[] pdf = await response.Content.ReadAsByteArrayAsync();DinkToPdf and other wkhtmltopdf wrappers
DinkToPdf is a P/Invoke wrapper around the wkhtmltopdf native library, and it still appears in many ASP.NET Core tutorials. Its last NuGet release, 1.0.8, was published in April 2017, and the last commit to its repository is from April 2018. The engine underneath is in worse shape: the wkhtmltopdf GitHub repository was archived on January 2, 2023, and the project's status page explains that it's built on QtWebKit, which Qt deprecated in 2015 and removed in 2016. The same page warns: "Do not use wkhtmltopdf with any untrusted HTML."
// Existing DinkToPdf code typically looks like this
using DinkToPdf;
var converter = new SynchronizedConverter(new PdfTools()); // register once, as a singleton
var document = new HtmlToPdfDocument
{
GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4 },
Objects = { new ObjectSettings { HtmlContent = html, WebSettings = { DefaultEncoding = "utf-8" } } },
};
byte[] pdf = converter.Convert(document);Practical consequences: flexbox and grid layouts don't render as designed, you ship a native libwkhtmltox binary per OS and architecture, and any user-supplied HTML is a security risk. Migrating to PuppeteerSharp is mostly mechanical. HtmlContent becomes SetContentAsync, GlobalSettings maps to PdfOptions, and wkhtmltopdf header placeholders become pageNumber and totalPages spans in FooterTemplate.
Commercial C# libraries: IronPDF, Syncfusion and iText
Searches for "best html to pdf converter c#" are dominated by vendor pages. Here's what each vendor's own site said in November 2026, without the marketing:
- IronPDF renders with Chromium (its NuGet description advertises "Chrome HTML to PDF Rendering"). Licenses are perpetual, from $999 for Lite (one developer, one application) up to $5,999 for Unlimited, with a fully functional 30-day trial. Its licensing FAQ says trial keys can be used for development and testing within an IDE.
- Syncfusion's HTML-to-PDF converter uses the Blink engine, per its product page. It's part of a commercial suite, but the Community License is free for companies and individuals with under $1 million in annual gross revenue, 5 or fewer developers and 10 or fewer employees, that have never taken more than $3 million in outside capital. Government organizations aren't eligible.
- iText pdfHTML is an add-on to iText Core that converts static HTML5 and CSS3 by mapping elements to iText's own layout objects, so it isn't a browser. It's dual-licensed: the AGPL, which requires you to disclose the full source of your application, or a commercial license. The NuGet package is now
itext.pdfhtml;itext7.pdfhtmlis deprecated.
If you're choosing between these and the free Chromium drivers, the real difference isn't rendering quality (IronPDF, Syncfusion, PuppeteerSharp and Playwright all print through Chromium). It's support, packaging and licensing. Compare that against the operational cost of running Chromium yourself.
Running on Linux, Docker and Azure
- Shared libraries: Chromium needs a set of Linux packages that slim .NET runtime images don't include. A typical symptom is a launch failure that names a missing
.sofile. - Playwright images: Microsoft publishes Docker images for Playwright .NET in the form
mcr.microsoft.com/playwright/dotnet:v1.64.1-noble(Ubuntu 24.04). Pin the tag to the same version as yourMicrosoft.Playwrightpackage. - PuppeteerSharp:
BrowserFetcherdownloads Chrome at runtime by default. In containers, either download it during the image build or install Chromium from the distro and pointLaunchOptions.ExecutablePathat it. - Fonts: a minimal image has almost none, so text falls back to whatever exists and CJK or emoji become empty boxes. Install the font packages your documents need.
- Sandbox: if Chrome refuses to start as root, run the app as a non-root user rather than reaching for
--no-sandbox, which is only acceptable for HTML you fully trust.
The headless Chrome in Docker guide has tested Dockerfiles. On any host, including Azure App Service, Azure Container Apps or AWS, a container image with Chromium's dependencies baked in is the most predictable setup.
Common problems and fixes
| Symptom | Cause | Fix |
|---|---|---|
| Backgrounds and colors missing | PrintBackground defaults to false (PuppeteerSharp and Playwright) | Set PrintBackground = true; add print-color-adjust: exact in CSS |
| Blank or partially missing text | Printed before web fonts loaded | await page.EvaluateExpressionHandleAsync("document.fonts.ready") before printing |
| Wrong paper size | Defaults to US Letter | Set Format = PaperFormat.A4 (PuppeteerSharp) or Format = "A4" (Playwright) |
| Footer missing or overlapping content | Templates sit inside the margins; no explicit font size | Increase MarginOptions.Bottom; style the template inline |
Razor compile errors in <style> | @media / @page parsed as Razor code | Write @@media and @@page |
| Flexbox or grid layout broken | wkhtmltopdf-based library (DinkToPdf and similar) | Move to a Chromium-based renderer |
| Chrome fails to launch in Docker | Missing Linux libraries or running as root | Use a Playwright image or install Chromium's dependencies; run as non-root |
| Memory grows with traffic | A browser launched per request, or pages not disposed | One browser per app, await using for every page, queue heavy jobs |
Call the RenderKit API from C# with HttpClient
If you'd rather not run Chromium at all, a hosted API turns HTML-to-PDF into one HTTP request. RenderKit has no .NET SDK; you don't need one. POST JSON to /v1/pdf with your x-api-key and the response contains a hosted PDF URL:
using System.Net.Http.Json;
using System.Text.Json;
var apiKey = Environment.GetEnvironmentVariable("RENDERKIT_API_KEY")
?? throw new InvalidOperationException("Set RENDERKIT_API_KEY");
using var http = new HttpClient(); // in ASP.NET Core, inject one via IHttpClientFactory
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.renderkit.tech/v1/pdf")
{
Content = JsonContent.Create(new
{
html, // or: url = "https://example.com/reports/q3"
page_format = "A4",
margin = "16mm",
footer_html =
"<div style='font-size:9px; width:100%; text-align:center;'>" +
"<span class='pageNumber'></span> / <span class='totalPages'></span></div>",
}),
};
request.Headers.Add("x-api-key", apiKey);
using var response = await http.SendAsync(request);
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
if (!response.IsSuccessStatusCode)
{
var error = body.GetProperty("error"); // { code, message, request_id }
throw new InvalidOperationException($"{error.GetProperty("code")}: {error.GetProperty("message")}");
}
var pdfUrl = body.GetProperty("data").GetProperty("url").GetString()!; // hosted on cdn.renderkit.tech
byte[] pdf = await http.GetByteArrayAsync(pdfUrl);
await File.WriteAllBytesAsync("invoice.pdf", pdf);- What changes: no Chromium, fonts or Linux packages in your image, and no browser memory in your web app. The same print features are request fields:
page_format,margin,landscape,scale,page_range,prefer_css_page_size, andheader_html/footer_htmlwith the samepageNumberandtotalPagesclasses.print_backgrounddefaults totrue. - Trade-offs: your HTML is sent to a third party and each render is a network call. Results are public, content-addressed URLs on
cdn.renderkit.tech, so copy private documents into your own storage. There's no SLA. - Cost: 2 credits per PDF; cache hits are free and failed renders are refunded. The free trial gives 500 credits for 14 days (10 requests per minute, 1 concurrent render, 15-second timeout); paid plans start at $9/month for 5,000 credits.
- Errors: failures come back as
{ success: false, error: { code, message } }, for exampleTIMEOUT(422) orRATE_LIMIT_EXCEEDED(429). Retry 429 and 503 after theRetry-Afterheader.
All parameters are in the PDF API reference, and status codes in errors. Comparing hosted services? See the best HTML to PDF APIs in 2026.
Related
The same comparison for other stacks: Node.js, Python, and Java. Engine deep-dives: Puppeteer PDF, Playwright PDF, and headless Chrome in Docker. Document recipes: invoice PDFs and reports.
Common questions
PuppeteerSharp. It's MIT-licensed, prints through real Chrome so flexbox, grid and web fonts render correctly, and supports page sizes, margins and header/footer templates. Playwright for .NET (MIT per NuGet) is an equally good free option. QuestPDF is free for companies under USD 1M in revenue, but it builds PDFs from C# code rather than HTML.
Render your Razor component to an HTML string with HtmlRenderer (.NET 8+), load it into a page from a singleton PuppeteerSharp browser with SetContentAsync, call PdfDataAsync with PdfOptions { Format = PaperFormat.A4, PrintBackground = true }, and return Results.File(bytes, "application/pdf", "invoice.pdf").
Not without a browser engine somewhere. With no NuGet packages you can start headless Chrome with Process and the --headless --print-to-pdf flags, or POST the HTML with HttpClient to a rendering service such as Gotenberg or a hosted HTML-to-PDF API.
No. Its last NuGet release (1.0.8) is from April 2017, and the wkhtmltopdf engine it wraps had its GitHub repository archived on January 2, 2023. wkhtmltopdf's status page also warns against using it with untrusted HTML. Use PuppeteerSharp or Playwright for new code.
For many companies, yes. As of November 2026 its Community license is free for individuals and organizations with annual gross revenue under USD 1,000,000, with exceptions: public-sector entities and publicly traded companies don't qualify. Larger companies need the Professional ($1,999) or Enterprise ($4,999) license. QuestPDF doesn't render HTML.
As of November 2026, IronPDF's licensing page lists perpetual licenses from $999 (Lite, one developer and one application) to $5,999 (Unlimited), with Enterprise on quote. A fully functional 30-day trial is available, and trial keys cover development and testing.
Yes, as long as Chromium's Linux dependencies and fonts are installed in the image. Download the browser during the image build (or point LaunchOptions.ExecutablePath at a distro Chromium), run as a non-root user, and reuse one browser across requests.
PuppeteerSharp and Playwright default PrintBackground to false, which removes background colors and images. Set PrintBackground = true, and add print-color-adjust: exact to elements whose colors must print exactly.
Ship your first render in 60 seconds.
500 free credits to start. No card. Cancel by ignoring it.