How to Convert Razor Pages to PDFs in ASP .NET Core Web App
Unlock the power of seamless PDF generation in your ASP.NET MVC applications by watching our step-by-step tutorial, and discover how IronPDF simplifies the process for creating stunning PDF documents with just a click!
In this tutorial, we explore how to convert CSHTML pages to PDF in an ASP.NET MVC web application using IronPDF. We begin by ensuring that IronPDF and its Blazor extension are installed. The process involves creating a simple Person
class with properties like ID, name, title, and description to represent data. Next, we focus on the Razor View, displaying a list of persons in a table format. Each person’s details are rendered, and a print button triggers the conversion to a PDF document. The magic happens in the person.cshtml.cs
file, where the OnGet
method populates the person's list with sample data. When the print button is clicked, the OnPostAsync
method uses the Chrome PDF renderer from IronPDF to transform the Razor page into a PDF document, which is then sent as a response to the browser for download. Navigation is facilitated through a nav link in the layout file. Running the project demonstrates the functionality: clicking the print button generates and downloads a beautifully rendered PDF document. The tutorial concludes by highlighting the ease of use IronPDF offers, encouraging users to start a free trial via a link provided in the description.