CSHTML到PDF (MVC Core)

该代码示例演示了将视图转换为PDF的过程。

两个包,IronPdf.Extensions.Mvc.CoreIronPdf,协同工作以实现将视图渲染为PDF。 IronPdf.Extensions.Mvc.Core包用作IronPdf的扩展,使得可以将视图渲染为PDF。

Use the RenderRazorViewToPdf method to render Views to PDFs. This method requires an IRazorViewRenderer, the path to the ".cshtml" file, and the data required to display on the ".cshtml" file. Please visit the How to Convert View to PDF in ASP.NET Core MVC how-to article to learn more.

This action also enables you to access the full range of features provided by the RenderingOptions class, such as applying page numbers in PDFs with IronPDF, adding text and HTML headers and footers with IronPDF, and customizing PDF paper size. The resulting PDF document can be further edited or exported as needed.

学习在 ASP.NET MVC Core 中将 CSHTML 视图转换为 PDF。

准备开始了吗?
Nuget 下载 16,685,821 | 版本: 2025.12 刚刚发布