// 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 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