CSHTML to PDF (Razor Pages)

This code example demonstrates the process of converting a Razor pages into PDFs.

To achieve this in an ASP.NET Core Web App, you'll require two packages: IronPdf.Extensions.Razor and IronPdf. These packages work together to enable the rendering of Razor pages into PDFs.

By rendering from Razor pages, you gain access to the full range of features provided by the RenderingOptions class. The resulting PDF document can be further edited or exported as needed.

How to Convert Razor Pages to PDFs in C#

  1. Install the C# library for converting Razor Pages to PDFs
  2. Instantiate the ChromePdfRenderer class
  3. Apply optional rendering options to customize the output PDF
  4. Pass the current Razor page to the RenderRazorToPdf method
  5. View the PDF document in the browser or download it to the desktop