Razor to PDF (Blazor Server)
This example demonstrates how a Razor component can be converted into a PDF document.
The IronPdf.Extensions.Blazor package is an extension of the main IronPdf package. To convert a Razor component's content page to a PDF, both the IronPdf.Extensions.Blazor and the primary IronPdf packages are required.
In the code example below, a model called PersonInfo has already been created. In the OnInitializedAsync method, we insert multiple new PersonInfo objects into the persons List. We then associate the persons List with the string "persons" in the Parameters dictionary.
In the PrintToPdf method, we instantiate the ChromePdfRenderer class. To convert the Razor component to a PDF document, we use the RenderRazorComponentToPdf method. In the code example, we pass the Parameters dictionary to the method for rendering.
How to Convert Razor Components to PDFs in Blazor Server
- Install IronPDF from NuGet for Razor component conversion in C#
- Prepare a model to store the information
- Instantiate the
ChromePdfRendererclass - Pass the
Dictionaryobject containing the data to theRenderRazorComponentToPdfAsyncmethod - Download the resulting PDF document to the desktop



