CSHTML 轉 PDF(MVC Core) 此程式碼範例展示了將視圖轉換為 PDF 的過程。 兩個套件,IronPdf.Extensions.Mvc.Core 與 IronPdf,共同協作以實現將視圖呈現為 PDF。 IronPdf.Extensions.Mvc.Core 套件作為 IronPdf 的擴展,啟用將視圖轉換為 PDF。 使用 RenderRazorViewToPdf 方法將視圖渲染為 PDF。 此方法需要一個 IRazorViewRenderer,".cshtml" 文件的路徑,以及顯示在 ".cshtml" 文件上的所需數據。請訪問如何將 ASP.NET Core MVC 中的視圖轉換為 PDF的文章以了解更多信息。 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. class="hsg-featured-snippet"> 如何在 ASP.NET MVC Core 中將 CSHTML 文件轉換為 PDF 安裝用於將 CSHTML 文件轉換為 PDF 的 C# 庫 實例化 ChromePdfRenderer 類 使用 RenderRazorViewToPdf 方法進行渲染 將 IRazorViewRenderer 對象和 CSHTML 文件路徑傳遞給方法 將生成的 PDF 文件下載到桌面 學習如何在 ASP.NET MVC Core 中將 CSHTML 視圖轉換為 PDF。 在 GitHub 上查看 程式碼 https://github.com/iron-software/IronPdf.Examples/tree/main/examples/cshtml-to-pdf-mvc-core 下載 ZIP 文件 相關教學 相關操作指南 類別文檔 取得語言包 下載 IronPDF DLL 回報此頁面的問題 準備好開始了嗎? Nuget 下載 16,154,058 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:16,154,058 查看許可證