Skip to content

§ Blazor HTML to PDF

Blazor HTML to PDF: Convert a Component or HTML to a Real PDF

Turn a Blazor component or raw HTML into a pixel accurate, searchable PDF with one API call, from Blazor Server or WebAssembly. Managed Chromium renders your real markup with full CSS, web fonts and JavaScript, so the file matches the page, no IronPDF license to buy and no browser engine to host and scale. Try it on any URL or HTML below.

  • Early access, launching soon
  • No card required
  • Your HTML stays yours

§ Live demo

Runs in your browser. Nothing is uploaded.

Your PDF is downloading. Want this as one API call, with the page archived too?

§ Short answer

To convert HTML to PDF in Blazor, you need something that turns your component markup into a PDF. Code-only libraries like QuestPDF and PDFsharp do not accept HTML by design, so you rebuild the layout in C#. Chromium-based libraries like IronPDF and Syncfusion do accept HTML with full CSS and JavaScript, but they are commercial and run server side only, so they cannot run inside a Blazor WebAssembly app. The route that works from both hosting models is to POST your component HTML, or a URL, to a rendering API. Sitepdf renders it in managed Chromium and returns a true, selectable vector PDF, plus an optional timestamped archive of exactly what it rendered.

Last updated July 2026. Written and fact checked by the Sitepdf team.

§ 00

Three ways to get a PDF out of Blazor, compared

Blazor has no built-in PDF export, and your hosting model matters: a WebAssembly app runs in the browser and cannot host a server-side PDF engine, while a Server app can. These three routes differ on HTML support, licensing and where they run.

Approach How it works HTML, CSS and JavaScript License and hosting Best for
IronPDF, Syncfusion
Chromium libraries
Bundle a Chromium engine and convert your HTML string or URL to PDF Full HTML5, CSS3 and JavaScript, selectable text Commercial license; runs server side only, not inside WebAssembly Teams already licensed that can render on the server
QuestPDF, PDFsharp
code path
You declare the document layout in C# with a fluent or drawing API No HTML input by design; true vector output you build by hand QuestPDF free under a revenue cap; runs anywhere .NET runs Structured invoices and reports you are happy to lay out in code
Managed Chromium API
Sitepdf
You POST your component HTML or a URL, a managed browser prints it Full modern CSS and JavaScript, it is a real current browser One HTTP call from Server or WebAssembly, no engine to host Production documents, exact fidelity, WebAssembly apps, a dated record

The honest read: QuestPDF is excellent and free under its revenue cap if you are happy to describe the document in C#, and IronPDF or Syncfusion are solid if you already pay for them and can render on the server. A rendering API earns its place when you are on Blazor WebAssembly and cannot run a server-side engine at all, when you want the PDF to match your Razor design instead of a hand-built layout, or when you do not want to license and host a Chromium engine yourself.

§ 01

First, your hosting model decides half the answer

Before you pick a library, look at how your app is hosted, because it rules options in or out. A Blazor WebAssembly app runs entirely in the user's browser, which means there is no server process to run a .NET PDF engine like IronPDF or Syncfusion. Those are server-side libraries, so from a WebAssembly app your only realistic choices are a purely client-side approach or a call out to an API. A Blazor Server app, by contrast, executes on your server, so you can run any server-side library there. This single fact is why so many Blazor PDF questions have contradictory answers online: the right tool depends on a hosting detail the question usually leaves out.

The other divide is the same one every stack faces: does a real browser render the document, or does a library draw it. QuestPDF and PDFsharp draw it in code, so they produce clean vector PDFs but never accept your HTML or CSS. IronPDF, Syncfusion and PuppeteerSharp drive a Chromium engine, so they render your actual markup with full CSS and JavaScript. A hosted API is the browser route without the browser: you send HTML, it renders in managed Chromium, and it works identically whether your app is Server or WebAssembly.

§ 02

The code libraries: QuestPDF and PDFsharp, and where they fit

It is worth being clear about QuestPDF, because it is popular and frequently suggested for this. QuestPDF does not convert HTML to PDF, and that is a deliberate design decision, not a missing feature. It gives you a fluent C# API to compose a document from rows, columns, tables and text, and for a structured invoice or report that you are content to lay out in code it is fast, has no browser overhead, and is free under its revenue threshold. PDFsharp and MigraDoc work the same way at a lower level. The trade is that none of them reuse your Razor markup or CSS: if you already have a nicely styled component, you are rebuilding it in a different language. When the document is genuinely code-shaped and small, that is fine. When it should look like a page your users already see, it is a lot of duplicated effort that drifts out of sync.

§ 03

The browser path: render your real component HTML

To get a PDF that matches your Blazor UI, a browser has to render it. The Chromium libraries (IronPDF, Syncfusion) do this on the server and are a good fit if you are licensed and hosting Blazor Server. The lighter route, and the only one that also works from WebAssembly, is to render your component to an HTML string and post it to an API. On the server you can produce that HTML with the built-in HtmlRenderer, or simply point the API at a live route in your app.

using System.Net.Http.Headers;

var form = new Dictionary<string, string>
{
    ["url"] = "https://app.example.com/invoices/8842",
    ["format"] = "Letter",
    ["archive"] = "true",
};

var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("SITEPDF_KEY"));

var resp = await http.PostAsync(
    "https://api.sitepdf.com/v1/render", new FormUrlEncodedContent(form));
var doc = await resp.Content.ReadFromJsonAsync<RenderResult>();

The browser does the layout, so your CSS, web fonts, background colors and any JavaScript charts render exactly as they do on screen, and the PDF text stays selectable and searchable. Nothing runs a Chromium engine inside your own process, which keeps a WebAssembly app viable and a Server app light. Our HTML to PDF in C# guide covers the same call from a plain .NET server with the library options, and the PDF generator API page lists every parameter.

§ 04

Keep a dated copy of what you generated

A generated invoice, contract or statement leaves your Blazor app and nothing verifiable stays with you. Add archive=true to the render call and Sitepdf also stores a timestamped, immutable snapshot of exactly what it rendered, retrievable by id later, so you can prove what a document said on a given date. For finance and compliance work that provenance is often the whole point of rendering server side. The website archiving page explains how the record works, and if you are weighing running your own headless Chromium instead, the Puppeteer alternative page runs that trade off honestly. Renders are transient by default; leave archiving off and we return the PDF and store nothing.

Point the API at a Blazor route, or POST HTML you rendered on the server. Works from Server or WebAssembly.
curl https://api.sitepdf.com/v1/render \
  -H "Authorization: Bearer $SITEPDF_KEY" \
  -F url=https://app.example.com/invoices/8842 \
  -F format=Letter \
  -F print_background=true \
  -F archive=true

{
  "pdf_url": "https://api.sitepdf.com/v1/documents/doc_bz51n.pdf",
  "pages": 2,
  "rendered_in_ms": 1588,
  "archive": {
    "id": "arc_bz83k",
    "captured_at": "2026-07-19T21:09:33Z",
    "retrieve_url": "https://api.sitepdf.com/v1/archives/arc_bz83k"
  }
}

The API is in early access; this is the documented call shape it opens with. Full request and response walkthrough.

§ 05

Questions about this job

How do I convert HTML to PDF in Blazor?
Render your component to an HTML string on the server, or point at a live route, then convert that HTML to a PDF. A Chromium-based library like IronPDF or Syncfusion does this server side, and a rendering API does it over one HTTP call from either Blazor Server or WebAssembly, returning a searchable PDF with your CSS and JavaScript intact.
Can I generate a PDF in Blazor WebAssembly?
Not with a server-side library, because a WebAssembly app runs in the browser and cannot host IronPDF, Syncfusion or a headless engine. Your practical options are a purely client-side approach or, for real fidelity, calling a rendering API. The API renders your component HTML in managed Chromium on its own infrastructure and returns the PDF, which works fine from a WebAssembly app.
Is QuestPDF or IronPDF better for Blazor HTML to PDF?
They solve different problems. QuestPDF does not accept HTML at all; you build the document in C#, and it is free under a revenue cap and great for structured reports. IronPDF renders your actual HTML with full CSS and JavaScript through an embedded Chromium engine, which is what you want to match an existing page, but it is commercial and runs server side only.
Do I need a license to convert HTML to PDF in Blazor?
It depends on the tool. IronPDF and Syncfusion are commercial and require a paid license. QuestPDF is free below its revenue threshold and paid above it, but it does not convert HTML. A rendering API is billed per use with no engine to license or host, and it is the only route that works unchanged from a Blazor WebAssembly app.
How do I render a Blazor component with charts to PDF?
If the chart is drawn by JavaScript, you need a real browser to run it. Render the component to HTML and send it to a Chromium-based engine or a rendering API, which loads the page, runs the JavaScript, waits for the chart to finish, then prints it. The graph then appears in the PDF exactly as it does on screen, with the surrounding text still selectable.

§ Early access

Get on the early-access list

The API opens to the list first, in order. Early access locks the planned launch rates for 12 months. No card required, launching soon.

Render + archive, one API