使用IRONPDF .NET Core PDF庫 Curtis Chau 更新日期:9月 1, 2025 Download IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article IronPDF is available for Microsoft Windows .NET Framework 4.x, as well as a recent release for .NET Core 3.1 and the latest .NET version. IronPDF for .NET Core is available through the NuGet official page IronPdf package on NuGet. The current .NET Core release is cross-platform, supporting Linux, Unix, and macOS client operating systems, as well as Mono, with MAUI, and Blazor compatibility. Existing and new customers receive free upgrades to the .NET Core build of IronPDF within their existing Support & Upgrade coverage. This is provided with every IronPDF commercial license. This ensures your investment in IronPDF is future-proofed. Existing customers who wish to extend expired support & update cover can purchase an extension to the IronPDF license. IronPDF: A .NET PDF Library IronPDF is a C# PDF library that can be used in .NET Core projects. It provides all the necessary APIs to manipulate PDF documents straightforwardly and intuitively. There are other PDF-generating libraries on the market, but this library has been designed as simply as possible to avoid confusion. The main goal of this project is to provide a PDF library for .NET applications. It comes with many useful features, such as generating PDF files from HTML strings, converting PDFs to other formats, manipulating existing PDF documents, and generating PDF files directly from .NET Core projects. The IronPDF library also offers the ability to print PDF files with just a few lines of code. IronPDF can be used as a PDF converter. It can create multi-page spread tables using its accessible functions. Let's begin using the IronPDF library in our project. Create C# Project The latest version of Visual Studio is recommended for creating this .NET project to ensure a smooth user experience. The IronPDF library is also compatible with a .NET Core project. The choice depends on the user, as the installation and use of IronPDF are identical across all .NET Frameworks. Follow the steps below to create a project in Visual Studio. Start Visual Studio. Click on "Create a new project". Create a new project in Visual Studio Search for "Console" in the search field, and select "Console App" with the C# tag from the search results. Console App selection After that, configure the project name according to your requirements. Configure this new application After that, select the latest version of .NET Framework from the dropdown list. This is recommended. Next, click on the Create button. .NET Framework selection The project will now be created. You can also use existing .NET Core projects with IronPDF. First, you need to install the library. The next section shows how to install the library. Installation of the IronPDF Library To install the IronPDF library from the command line, run the following command: Install-Package IronPdf You can get more information on the IronPDF website and the IronPDF NuGet page. After installation, you will be able to use it in your .NET project. For more details about installation, visit the IronPDF installation guide. Code Example A web page for PDF files using IronPdf; var renderer = new ChromePdfRenderer(); // Choose Screen or Print CSS media renderer.RenderingOptions.CssMediaType = Rendering.PdfCssMediaType.Screen; // Set the width of the responsive virtual browser window in pixels renderer.RenderingOptions.ViewPortWidth = 1280; // Set the paper size of the output PDF renderer.RenderingOptions.PaperSize = Rendering.PdfPaperSize.A2; // Render the URL as PDF var pdf = renderer.RenderUrlAsPdf("https://www.amazon.com/"); // Save the PDF to a local file pdf.SaveAs("Amazon.pdf"); using IronPdf; var renderer = new ChromePdfRenderer(); // Choose Screen or Print CSS media renderer.RenderingOptions.CssMediaType = Rendering.PdfCssMediaType.Screen; // Set the width of the responsive virtual browser window in pixels renderer.RenderingOptions.ViewPortWidth = 1280; // Set the paper size of the output PDF renderer.RenderingOptions.PaperSize = Rendering.PdfPaperSize.A2; // Render the URL as PDF var pdf = renderer.RenderUrlAsPdf("https://www.amazon.com/"); // Save the PDF to a local file pdf.SaveAs("Amazon.pdf"); Imports IronPdf Private renderer = New ChromePdfRenderer() ' Choose Screen or Print CSS media renderer.RenderingOptions.CssMediaType = Rendering.PdfCssMediaType.Screen ' Set the width of the responsive virtual browser window in pixels renderer.RenderingOptions.ViewPortWidth = 1280 ' Set the paper size of the output PDF renderer.RenderingOptions.PaperSize = Rendering.PdfPaperSize.A2 ' Render the URL as PDF Dim pdf = renderer.RenderUrlAsPdf("https://www.amazon.com/") ' Save the PDF to a local file pdf.SaveAs("Amazon.pdf") $vbLabelText $csharpLabel This example shows how to convert a complex website UI to PDF, for example, the Amazon website, by following these steps: Set the Media Type to Screen Set the viewport width Set the paper size of the output PDF. Page size is a significant factor in PDF files Render the URL to PDF, using the Amazon URL as a source Output Output PDF file rendered from Amazon website Simple PDF Creation using IronPdf; // Instantiate renderer var renderer = new IronPdf.ChromePdfRenderer(); // Create a PDF from an HTML string using C# using var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); // Export to a file or Stream pdf.SaveAs("output.pdf"); /****** Advanced Example with HTML Assets ******/ // Load external html assets: images, CSS, and JavaScript. // An optional BasePath 'C:\\site\\assets\\' is set as the file location to load assets from using var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\"); // Save the PDF with assets to a file myAdvancedPdf.SaveAs("html-with-assets.pdf"); using IronPdf; // Instantiate renderer var renderer = new IronPdf.ChromePdfRenderer(); // Create a PDF from an HTML string using C# using var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); // Export to a file or Stream pdf.SaveAs("output.pdf"); /****** Advanced Example with HTML Assets ******/ // Load external html assets: images, CSS, and JavaScript. // An optional BasePath 'C:\\site\\assets\\' is set as the file location to load assets from using var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\"); // Save the PDF with assets to a file myAdvancedPdf.SaveAs("html-with-assets.pdf"); Imports IronPdf ' Instantiate renderer Private renderer = New IronPdf.ChromePdfRenderer() ' Create a PDF from an HTML string using C# Private pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>") ' Export to a file or Stream pdf.SaveAs("output.pdf") '''**** Advanced Example with HTML Assets ***** ' Load external html assets: images, CSS, and JavaScript. ' An optional BasePath 'C:\\site\\assets\\' is set as the file location to load assets from Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\") ' Save the PDF with assets to a file myAdvancedPdf.SaveAs("html-with-assets.pdf") $vbLabelText $csharpLabel The code above demonstrates how to use the HTML-to-PDF functionality of IronPDF. To use IronPDF, importing the namespace is necessary. Write using IronPdf; at the top of the program file to use it in the project. The ChromePdfRenderer object is available for web support. The RenderHtmlAsPdf function can be used for converting HTML strings to PDF files. The function parameter accepts various types of sources, including an HTML string. You can also use images in your PDF document by setting the base path of images. After that, the SaveAs function is used to save the PDF file locally. You can choose simple HTML like the above and incorporate CSS, images, and JavaScript. Output PDF file output from Hello World HTML text Headers & Footers // Initialize the first page number renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a cover page will be appended // Set header options renderer.RenderingOptions.TextHeader.DrawDividerLine = true; renderer.RenderingOptions.TextHeader.CenterText = "{url}"; renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica; renderer.RenderingOptions.TextHeader.FontSize = 12; // Initialize the first page number renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a cover page will be appended // Set header options renderer.RenderingOptions.TextHeader.DrawDividerLine = true; renderer.RenderingOptions.TextHeader.CenterText = "{url}"; renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica; renderer.RenderingOptions.TextHeader.FontSize = 12; ' Initialize the first page number renderer.RenderingOptions.FirstPageNumber = 1 ' use 2 if a cover page will be appended ' Set header options renderer.RenderingOptions.TextHeader.DrawDividerLine = True renderer.RenderingOptions.TextHeader.CenterText = "{url}" renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica renderer.RenderingOptions.TextHeader.FontSize = 12 $vbLabelText $csharpLabel The above example demonstrates how to set headers and footers in the PDF file. IronPDF supports repeating headers in the document. IronPDF provides TextHeader and TextFooter properties to set various attributes of text, such as fonts, text position, etc. It can also convert HTML files to PDF files. Everything is straightforward with IronPDF. It can also merge PDF files efficiently, perform webpage-to-PDF conversions, enable automatic page numeration, and create digital signatures for PDFs using IronPDF. Furthermore, it produces PDF files of minimal file size with efficient compression. Summary IronPDF is a complete PDF library that supports all the latest versions of .NET Core and .NET Frameworks. IronPDF is based on a business model that offers a secure way to create and edit business documents using the IronPDF library. Its advanced features enable the user to create dynamic and creative PDF documents in .NET Core projects. There is the option to try the free trial for production testing. IronPDF Professional license You can also currently buy the suite of five Iron Software packages for the price of just two. Get more information from the IronPDF licensing page. 常見問題解答 如何在.NET Core中從HTML產生PDF檔? 您可以使用 IronPDF 的RenderHtmlAsPdf方法在 .NET Core 中從 HTML 產生 PDF 文件,該方法可讓您將 HTML 字串或文件直接轉換為 PDF 文件。 IronPDF 是否相容於跨平台開發? 是的,IronPDF 與跨平台開發相容,並支援 Windows、Linux、Unix 和 macOS 等作業系統,使其能夠靈活應用於各種部署環境。 如何將 PDF 庫整合到我的 .NET Core 專案中? 您可以透過 NuGet 安裝 IronPDF,將其整合到您的 .NET Core 專案中。只需在專案目錄中執行命令dotnet add package IronPdf即可。 我可以使用 IronPDF 將網頁轉換為 PDF 嗎? 是的,IronPDF 提供了將整個網頁轉換為 PDF 的功能,它可以直接將 URL 渲染成 PDF 格式,從而方便地歸檔網頁內容。 IronPDF是否支援為PDF新增頁首和頁尾? IronPDF 支援在 PDF 文件中新增頁首和頁尾,從而實現一致且專業的文件格式。 使用 IronPDF 進行 PDF 處理有哪些好處? IronPDF 具有易於使用、強大的 PDF 操作 API、跨平台支援以及合併 PDF 和添加數位簽章等功能等優點。 IronPDF 是否提供 PDF 檔案壓縮功能? 是的,IronPDF 提供高效的文件壓縮選項,確保您的 PDF 文件在不影響品質的前提下保持最小的大小。 IronPDF有免費試用版嗎? IronPDF 提供免費試用版,使用者可以在生產環境中測試其功能,然後再做出購買決定。 如何在現有的 .NET Core 專案中更新 IronPDF? 若要在現有的 .NET Core 專案中更新 IronPDF,可以使用 NuGet 套件管理器檢查更新並根據需要套用更新,以確保您擁有最新的功能和修復程式。 哪裡可以找到IronPDF的許可資訊? IronPDF 的許可資訊可在其官方網站上找到,其中提供了不同許可選項和支援計劃的詳細資訊。 IronPDF 是否完全相容於 .NET 10? 是的,IronPDF 支援最新的 .NET 版本,包括 .NET 10。產品頁面明確提及了與 .NET 10、9、8、7、6、.NET Standard 和 .NET Framework 的兼容性。使用者可以在 .NET 10 的專案中使用 IronPDF 的所有功能。 IronPDF 在針對 .NET 10 時支援哪些平台和專案類型? 將 IronPDF 與 .NET 10 結合使用時,您可以建立適用於 Windows、Linux 和 macOS 的應用,包括 Docker、Azure 和 AWS 環境。支援的 .NET 專案類型包括 Web 應用(例如 Blazor、MVC)、桌面應用程式(WPF 和 MAUI)、控制台應用程式和程式庫應用程式。 IronPDF 可原生運行,無需任何變通方案。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 相關文章 發表日期 11月 13, 2025 如何在 C# 中合併兩個 PDF 位元組數組 使用 IronPDF 在 C# 中合併兩個 PDF 位元組數組。學習如何透過簡單的程式碼範例,將來自位元組數組、記憶體流和資料庫的多個 PDF 文件合併在一起。 閱讀更多 發表日期 11月 13, 2025 如何在 ASP.NET MVC 中創建 PDF 檢視器 為 ASP.NET MVC 應用程式構建一個強大的 PDF 檢視器。顯示 PDF 文件,將視圖轉換為 PDF,使用 IronPDF 添加互動功能。 閱讀更多 發表日期 11月 13, 2025 如何建立 .NET HTML 轉 PDF 轉換器 學習如何在.NET中使用IronPDF將HTML轉換為PDF。 閱讀更多 將 ASPX 轉換為 PDFC#創建PDF(代碼示例教程)
發表日期 11月 13, 2025 如何在 C# 中合併兩個 PDF 位元組數組 使用 IronPDF 在 C# 中合併兩個 PDF 位元組數組。學習如何透過簡單的程式碼範例,將來自位元組數組、記憶體流和資料庫的多個 PDF 文件合併在一起。 閱讀更多
發表日期 11月 13, 2025 如何在 ASP.NET MVC 中創建 PDF 檢視器 為 ASP.NET MVC 應用程式構建一個強大的 PDF 檢視器。顯示 PDF 文件,將視圖轉換為 PDF,使用 IronPDF 添加互動功能。 閱讀更多