Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To generate a styled PDF from an HTML string in Blazor, render the HTML with a PDF engine on a server, save the result to a stream or byte array, then deliver it to the browser. A concrete documented option is Syncfusion’s HTML-to-PDF converter: its Blazor documentation supports server-side Blazor, but explicitly excludes Blazor WebAssembly. The conversion engine’s runtime compatibility and the method used to download the PDF are separate decisions.
How the HTML-to-PDF pipeline works
HTML-to-PDF conversion is not simply a browser download operation. A rendering engine must interpret your markup and CSS, resolve any required resources, lay out pages, and produce PDF data. In a Blazor application, the overall flow is:
- Build or collect the HTML string and its CSS.
- Call an HTML-to-PDF renderer in an execution environment it supports.
- Set relevant conversion options, such as viewport or page layout, using the API for your installed package version.
- Write the resulting PDF to a stream or byte array.
- Return the PDF from a server endpoint or send a stream to the browser for download or display.
Syncfusion’s Blazor walkthrough demonstrates a conversion service that writes a PDF document to a MemoryStream and uses JavaScript interop to deliver it. Its documentation lists HTML strings as a supported input type, although the displayed Blazor conversion example converts a URL. Keep that distinction in mind: use the HTML-string overload documented for the exact package version you install rather than assuming the URL example is interchangeable with a string call. See Syncfusion’s Blazor HTML-to-PDF documentation.
Choose where conversion runs
Server-side Blazor
For the documented Syncfusion Blazor workflow, run conversion on the server. Syncfusion states that its HTML-to-PDF conversion is supported only in Blazor Server-side, not in Blazor WebAssembly. Microsoft’s render-mode documentation distinguishes Interactive Server, which runs on the server, from Interactive WebAssembly, which runs in the browser. These are important constraints: a converter’s own support matters in addition to the Blazor render mode. See Microsoft’s Blazor render-modes documentation.
#1 Best Overall
Blazor WebAssembly
Do not place this Syncfusion conversion call in WebAssembly client code and assume it will work there. If the UI is a WebAssembly app and you want to use this converter, a reasonable architecture is to send the HTML or a document request to a server-side service or API that performs the conversion, then return the PDF. That is an architectural design inference, not an end-to-end WebAssembly-to-API sample established by the cited documentation. Verify the approach, data flow, and security requirements for your application and converter.
Install and configure the Syncfusion converter
Syncfusion’s current Blazor and ASP.NET Core conversion pages identify the NuGet package Syncfusion.HtmlToPdfConverter.Net.Windows, describe Blink as the rendering engine, and list compatibility with .NET 8.0 and later. The package name includes “Windows”; the reviewed documentation does not establish support for every operating system, container image, or processor architecture. Before deployment, check the package-specific prerequisites for the target host rather than extrapolating from the framework version alone.
The documentation also says that beginning with version 16.2.0.x, assemblies referenced from trial setup or the NuGet feed require a Syncfusion.Licensing reference and license-key registration. Treat that as Syncfusion-specific guidance, not a universal rule for PDF libraries. Check the applicable licensing and registration steps for your installed package and distribution arrangement. See Syncfusion’s ASP.NET Core HTML-to-PDF documentation.
Recommended Free Tools
Convert an HTML string without assuming the wrong overload
The product documentation lists direct HTML strings among the supported inputs, along with URLs, local HTML files, MHTML, authenticated pages, and HTTP GET or POST content. However, the Blazor walkthrough’s shown CreatePdf example calls Convert(url), not a literal HTML-string overload. Do not silently substitute a guessed method signature into that sample: consult the API reference and examples for the package version in your project, then use the overload and settings actually exposed there.
Rank #2
Conceptually, a server-side export service should accept or construct the markup, pass it to the converter’s documented HTML-string entry point, save the produced PDF to a stream, and return or forward that stream. Syncfusion’s walkthrough documents the service-and-stream pattern, but its URL-based code should not be represented as tested HTML-string code. This is especially important when HTML depends on external stylesheets, images, custom fonts, scripts, or relative paths: the available sources establish supported input categories, not a guarantee that every resource or CSS behavior will render as expected.
Deliver the PDF to the browser
Stream through Blazor JavaScript interop
For an in-app Blazor action, a stream can be passed to JavaScript with Microsoft’s DotNetStreamReference pattern. JavaScript reads the stream, creates a browser Blob with PDF media type, and can create an object URL for display or download. Microsoft documents this general document-streaming approach; adapt its browser-side code and cleanup behavior to the desired user experience. See Microsoft’s Blazor document and file-download guidance.
Return bytes from an HTTP endpoint
Another option is to expose a server endpoint that returns the PDF bytes with the application/pdf content type. Syncfusion’s ASP.NET Core example demonstrates returning a PDF file from a controller. This can be useful when the UI should navigate to a document URL or use a normal browser download flow; account for authentication and authorization if the generated file contains user-specific data.
Both approaches ultimately deliver PDF data, but they differ in how the browser receives it. Use streaming interop for a Blazor-controlled interaction; use an HTTP response when a resource endpoint fits your application. In either case, avoid treating a file name, media type, or download link as a substitute for protecting the underlying document request.
Preserve styling and validate the rendered result
HTML and CSS rendering is not a guarantee of pixel-identical output across every browser-oriented engine or deployment environment. The sources describe Blink settings, including viewport size in an ASP.NET Core example, but do not establish fidelity guarantees for arbitrary CSS, JavaScript timing, embedded fonts, or print-specific styling. Validate a representative document in the environment where conversion will run.
- Check page size, orientation, margins, and page breaks on short and long documents.
- Confirm fonts and images are available to the renderer; remote resources may require network access and valid URLs.
- Test relative asset paths, authenticated resources, and any headers or cookies the page needs.
- Decide whether the HTML should use screen or print-oriented styling, and verify the actual output.
- Test long content, tables, and elements near page boundaries for clipping or unexpected splits.
- Run the conversion in the intended operating system, container, and architecture, using the package’s deployment prerequisites.
These are implementation checks, not claims of a particular defect rate or performance result. No benchmark or universal page limit is established by the cited material.
Troubleshooting common failures
The converter fails in WebAssembly
Cause: The documented Syncfusion Blazor conversion support is server-side only. Fix: move conversion into server-side code or a server API boundary and keep the WebAssembly client responsible for requesting and receiving the resulting PDF.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchThe HTML-string method does not compile
Cause: The displayed Blazor walkthrough uses a URL call, and overloads or option names can vary by package version. Fix: check the API reference for the installed package and choose its documented HTML-string overload; do not infer a signature from the URL sample.
Rank #4
The PDF is blank or missing images and styles
Possible causes: referenced resources are inaccessible to the renderer, paths resolve differently on the server, or conversion occurs before required content is available. The reviewed sources do not establish a universal fix for these cases. Fix: verify resource URLs and server access, supply the required authentication context where supported, and test the smallest HTML sample that reproduces the issue. Confirm each relevant conversion option against the package version.
The file arrives but does not open as a PDF
Possible causes: the response is not carrying the generated PDF bytes, the endpoint uses an incorrect media type, or the stream position is not at the beginning before it is read. Fix: inspect the response body and content type, confirm the converter successfully saved the document, and ensure your stream-delivery code reads the complete PDF from the intended position. Microsoft’s streaming guidance is a useful reference for the browser handoff.
Deployment works locally but fails on the host
Cause: the documented Windows package name and framework compatibility do not by themselves prove support for every deployment OS, container, or architecture. Fix: check Syncfusion’s prerequisites for the actual package and target host, then validate conversion in that environment before release.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Alternative for screenshot-style output: ScreenshotNeo
If the actual goal is a screenshot of a web page rather than a PDF generated inside your Blazor application, ScreenshotNeo is a separate website screenshot API and MCP server from Yorker Media. It is not a replacement for the server-side HTML-string-to-PDF workflow above: its API returns a screenshot or PDF of a URL, rather than serving as the documented Syncfusion converter. It may fit when your source is already a hosted page and you want a one-call capture.
Best Value
Or skip the browser setup
For a URL capture, a single request can return a PDF; set the output format using the documented API option for your use case. The basic request shape is:
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-o shot.pdf
See the ScreenshotNeo API documentation for PDF options and request parameters. ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report 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 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Create a free ScreenshotNeo account to try the API.
Frequently Asked Questions
Does Syncfusion support HTML strings as input?
Its documentation lists HTML strings as a supported input type. The Blazor walkthrough’s displayed conversion call uses a URL, so confirm the HTML-string overload for your installed package version.
Can I use the Syncfusion Blazor converter in WebAssembly?
Syncfusion’s documented Blazor HTML-to-PDF conversion supports server-side Blazor, not Blazor WebAssembly.
Does ScreenshotNeo convert an in-memory Blazor HTML string to PDF?
The documented ScreenshotNeo request captures a URL; it is a different use case from passing an in-memory HTML string to a Blazor PDF renderer.
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.
Free tools Windows power users keep installed
One-click scans. No signup required.

