IronPDF .NET Core Razor Component Extension provides Razor page utility methods such as converting Razor Page model to PDF. Requires the IronPdf package.
$ dotnet add package IronPdf.Extensions.BlazorSupports web applications and websites developed in Blazor Server App using .NET Core.
The IronPDF Blazor Server App extension provides utility methods, such as , to convert Razor Components into PDF documents in a Blazor Server project. The main is still required to achieve this.
RenderRazorComponentToPdfPlease visit "How to Convert Razor to PDF in Blazor Server" for a comprehensive guide on how to use the package.
@using IronPdf;
@using IronPdf.Extensions.Blazor;
@code {
[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);
}
}Note: This package installs only as an extension, and you also need to install the IronPDF package to use it in your application.
For more support and inquiries, please email us at: support@ironsoftware.com