IRONSOFTWAREHOME
Razor to PDF (Blazor Server)

// PM > Install-Package IronPdf.Extensions.Blazor

[Parameter]
public IEnumerable<PersonInfo> persons { get; set; }
public Dictionary<string, object> Parameters { get; set; } = new Dictionary<string, object>();

protected override async Task OnInitializedAsync()
{
    persons = new List<PersonInfo>
    {
        new PersonInfo { Name = "Alice", Title = "Mrs.", Description = "Software Engineer" },
        new PersonInfo { Name = "Bob", Title = "Mr.", Description = "Software Engineer" },
        new PersonInfo { Name = "Charlie", Title = "Mr.", Description = "Software Engineer" }
    };
}
private async void PrintToPdf()
{
    ChromePdfRenderer renderer = new ChromePdfRenderer();

    // Apply text footer
    renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
        {
            LeftText = "{date} - {time}",
            DrawDividerLine = true,
            RightText = "Page {page} of {total-pages}",
            Font = IronSoftware.Drawing.FontTypes.Arial,
            FontSize = 11
        };

    Parameters.Add("persons", persons);

    // Render razor component to PDF
    PdfDocument pdf = renderer.RenderRazorComponentToPdf<Person>(Parameters);

    File.WriteAllBytes("razorComponentToPdf.pdf", pdf.BinaryData);
}
' PM > Install-Package IronPdf.Extensions.Blazor

<Parameter>
Public Property persons As IEnumerable(Of PersonInfo)
Public Property Parameters As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()

Protected Overrides Async Function OnInitializedAsync() As Task
    persons = New List(Of PersonInfo) From {
        New PersonInfo With {.Name = "Alice", .Title = "Mrs.", .Description = "Software Engineer"},
        New PersonInfo With {.Name = "Bob", .Title = "Mr.", .Description = "Software Engineer"},
        New PersonInfo With {.Name = "Charlie", .Title = "Mr.", .Description = "Software Engineer"}
    }
End Function

Private Async Sub PrintToPdf()
    Dim renderer As New ChromePdfRenderer()

    ' Apply text footer
    renderer.RenderingOptions.TextFooter = New TextHeaderFooter() With {
        .LeftText = "{date} - {time}",
        .DrawDividerLine = True,
        .RightText = "Page {page} of {total-pages}",
        .Font = IronSoftware.Drawing.FontTypes.Arial,
        .FontSize = 11
    }

    Parameters.Add("persons", persons)

    ' Render razor component to PDF
    Dim pdf As PdfDocument = renderer.RenderRazorComponentToPdf(Of Person)(Parameters)

    File.WriteAllBytes("razorComponentToPdf.pdf", pdf.BinaryData)
End Sub
NuGet Download
PM > Install-Package IronPdf
Razor to PDF (Blazor Server)

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.

Learn to Convert Razor Components to PDF in Blazor Server
View on GitHub

Ready to Get Started?

Nuget Downloads 21,105,021Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999