CSHTML to PDF (MVC Framework) This code example illustrates how to convert Views into PDF documents. To achieve this, we utilize two packages: IronPdf.Extensions.Mvc.Framework and IronPdf, which work to facilitate the rendering of Views as PDFs. The IronPdf.Extensions.Mvc.Framework package extends the capabilities of IronPdf, specifically enabling the rendering of Views into PDFs. To perform the conversion, use the RenderView method. This method requires a few key inputs: an HttpContext, the path to the ".cshtml" file, and the necessary data to populate the ".cshtml" template. By invoking the 'Persons' action, you can seamlessly render the current View into a PDF document. Additionally, you have access to a comprehensive set of functionalities offered by the RenderingOptions class. These include the ability to add page numbers with IronPDF, insert text and HTML headers and footers using IronPDF, and customize the PDF paper size to your requirements. You have the flexibility to make further modifications or export the resulting PDF document as necessary. How to Convert CSHTML Files to PDFs in C# Install the IronPDF C# library for converting CSHTML files to PDFs in the ASP.NET MVC Framework Instantiate the ChromePdfRenderer class Pass the current HttpContext and the CSHTML file path to the RenderView method View the PDF document in the browser or download it to the desktop Explore the CSHTML to PDF Conversion Guide View on GitHub Code https://github.com/iron-software/IronPdf.Examples/tree/main/examples/cshtml-to-pdf-mvc-framework Download ZIP Related Tutorial Related How-To Guide Class Documentation Get Language Packs Download IronPDF DLL Report an Issue on this page Ready to Get Started? Nuget Downloads 16,315,602 | Version: 2025.11 just released Free NuGet Download Total downloads: 16,315,602 View Licenses
All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)