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 剛發表