IronPDF .NET Core Razor Page Extension provides Razor Page utility methods such as converting Razor Page model to PDF. Requires the IronPdf package.
$ dotnet add package IronPdf.Extensions.RazorSupports web applications and websites developed with .Net Core Razor Pages
The IronPDF .NET Core Razor Pages extension provides utility methods such as RenderRazorToPdf that are used to convert Razor Pages to PDFs and require the main IronPdf package.
Please visit "How to Convert Razor Pages to PDFs in ASP.NET Core Web App" for a comprehensive guide on how to use the package.
using AutoFixture;
using IronPdf.Razor.Pages;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Models;
namespace IronPdf.Razor.Page.Extension.Demo.Pages
{
public class PersonsModel : PageModel
{
[BindProperty(SupportsGet = true)]
public List<Person> persons { get; set; }
public void OnGet()
{
persons = new List<Person>();
var _fixture = new Fixture();
persons = _fixture.CreateMany<Person>(10).ToList();
ViewData["persionList"] = persons;
}
public IActionResult OnPostAsync()
{
persons = new List<Person>();
var _fixture = new Fixture();
persons = _fixture.CreateMany<Person>(10).ToList();
ViewData["persionList"] = persons;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderRazorToPdf(this);
Response.Headers.Add("Content-Disposition", "inline");
return File(pdf.BinaryData, "application/pdf");
}
}
}
Note: This package only installs as an extension and you need to install the IronPDF package as well to use in your application.
For more support and inquiries, please email us at: support@ironsoftware.com