IronPDF 開始使用 IronPDF 相關設定指南、部署和平台配置。 IronPDF 快速入門指南 Curtis Chau 更新:2025年10月20日 下載 IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 安裝 IronPDF,只需五分鐘即可建立您的第一個 PDF 檔案。憑藉其簡潔易用的 API,您可以將 HTML、DOCX、圖像等多種格式的檔案轉換為像素級完美的 PDF 檔案。 1. 先決條件 .NET Framework 4.6.2+ 或 .NET Core 3.1+ 或 .NET 5+ Visual C++ Redistributable (適用於 Windows)。 2. 安裝 IronPDF 標準版 IronPDF 安裝程式在本地運行。 如果您想在 Docker/微服務上進行部署,請查看遠端引擎模式指南。 立即開始使用 NuGet 建立 PDF 檔案: 使用 NuGet 套件管理器安裝 IronPDF PM > Install-Package IronPdf 複製並運行這段程式碼。 IronPdf.ChromePdfRenderer .StaticRenderHtmlAsPdf("<p>Hello World</p>") .SaveAs("pixelperfect.pdf"); 部署到您的生產環境進行測試 立即開始在您的專案中使用 IronPDF,免費試用! 免費試用30天 NuGet 套件管理器 DLL 下載 前往IronPDF NuGet 庫: 在解決方案資源管理器中,以滑鼠右鍵按一下"引用"。 選擇"管理 NuGet 套件">"瀏覽">搜尋 IronPdf Install-Package IronPdf 下載IronPDF DLL 套件 將適用於您作業系統的 ZIP 檔案解壓縮到解決方案目錄中的某個位置。 在 Visual Studio 解決方案資源管理器中,以滑鼠右鍵按一下"依賴項"。 "新增項目引用" > 選擇"瀏覽"以包含從 zip 檔案中提取的所有 DLL 檔案。 相關內容:更多關於配置設定的信息 平台專屬指南 Windows Linux MacOS Docker Azure AWS 3. 應用許可證密鑰 當您購買IronPDF 授權或選擇開始 30 天試用期時,許可證金鑰將會傳送到您的電子郵件。 複製密鑰並將其添加到應用程式的開頭。 IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"; IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"; IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY" $vbLabelText $csharpLabel 查看 IronPDF 許可 4. 創建你的第一個PDF IronPDF 可協助您建立 PDF 文件,或將 HTML、DOCX、RTF、Markdown 和映像轉換為 PDF,並保持文件格式的完整還原度。了解更多 PDF 轉換類型。 將此程式碼新增至您的 .cs 檔案頂部。 using IronPdf; using IronPdf; Imports IronPdf $vbLabelText $csharpLabel 建立空白 PDF 將 HTML 字串轉換為 PDF 將 DOCX 轉換為 PDF 建立 PDF 物件最簡單的方法只需指定寬度和高度。此PdfDocument建構函數會建立一個空白 PDF,可供使用者進行自訂。 using IronPdf; PdfDocument pdf = new PdfDocument(270, 270); pdf.SaveAs("blankPage.pdf"); using IronPdf; PdfDocument pdf = new PdfDocument(270, 270); pdf.SaveAs("blankPage.pdf"); Imports IronPdf Dim pdf As New PdfDocument(270, 270) pdf.SaveAs("blankPage.pdf") $vbLabelText $csharpLabel 使用ChromePdfRenderer.RenderHtmlAsPdf方法,您可以使用嵌入式 Chromium 引擎將任何 HTML(包括 HTML5)轉換為 PDF。 using IronPdf; IronPdf.ChromePdfRender .StaticRenderHtmlAsPdf("<p>Hello Word</p>") .SaveAs("string-to-pdf.pdf"); using IronPdf; IronPdf.ChromePdfRender .StaticRenderHtmlAsPdf("<p>Hello Word</p>") .SaveAs("string-to-pdf.pdf"); Imports IronPdf IronPdf.ChromePdfRender.StaticRenderHtmlAsPdf("<p>Hello Word</p>").SaveAs("string-to-pdf.pdf") $vbLabelText $csharpLabel 相關教學:如何在 C# 中將 HTML 字串轉換為 PDF 使用DocxToPdfRenderer類別將 Word 文件轉換為 PDF,您可以將 DOCX 檔案直接渲染為可自訂的 PDF,以便無縫整合到 .NET 應用程式中。 using IronPdf; DocxToPdfRenderer renderer = new DocxToPdfRenderer(); PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx"); pdf.SaveAs("pdfFromDocx.pdf"); using IronPdf; DocxToPdfRenderer renderer = new DocxToPdfRenderer(); PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx"); pdf.SaveAs("pdfFromDocx.pdf"); Imports IronPdf Private renderer As New DocxToPdfRenderer() Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx") pdf.SaveAs("pdfFromDocx.pdf") $vbLabelText $csharpLabel 相關教學:如何在 C# 中將 Microsoft Word 轉換為 PDF 5. 更多進階範例 除了簡單的 PDF 建立和轉換功能外,IronPDF 還提供更強大的 PDF 自訂選項。 新增頁首和頁尾 編輯文字 合併PDF 透過實例化TextHeaderFooter 、新增文字並將其附加到 PDF 來建立文字頁首或頁尾。 using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>"); // Create text header TextHeaderFooter textHeader = new TextHeaderFooter { CenterText = "This is the header!", }; // Create text footer TextHeaderFooter textFooter = new TextHeaderFooter { CenterText = "This is the footer!", }; // Add text header and footer to the PDF pdf.AddTextHeaders(textHeader); pdf.AddTextFooters(textFooter); pdf.SaveAs("addTextHeaderFooter.pdf"); using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>"); // Create text header TextHeaderFooter textHeader = new TextHeaderFooter { CenterText = "This is the header!", }; // Create text footer TextHeaderFooter textFooter = new TextHeaderFooter { CenterText = "This is the footer!", }; // Add text header and footer to the PDF pdf.AddTextHeaders(textHeader); pdf.AddTextFooters(textFooter); pdf.SaveAs("addTextHeaderFooter.pdf"); Imports IronPdf Dim renderer As New ChromePdfRenderer() Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>") ' Create text header Dim textHeader As New TextHeaderFooter With { .CenterText = "This is the header!" } ' Create text footer Dim textFooter As New TextHeaderFooter With { .CenterText = "This is the footer!" } ' Add text header and footer to the PDF pdf.AddTextHeaders(textHeader) pdf.AddTextFooters(textFooter) pdf.SaveAs("addTextHeaderFooter.pdf") $vbLabelText $csharpLabel 相關教學文章:如何新增頁首和頁腳 使用RedactTextOnAllPages可以輕鬆編輯文本,刪除整個文件中的短語。 using IronPdf; PdfDocument pdf = PdfDocument.FromFile("novel.pdf"); // Redact 'Alaric' phrase from all pages pdf.RedactTextOnAllPages("Alaric"); pdf.SaveAs("redacted.pdf"); using IronPdf; PdfDocument pdf = PdfDocument.FromFile("novel.pdf"); // Redact 'Alaric' phrase from all pages pdf.RedactTextOnAllPages("Alaric"); pdf.SaveAs("redacted.pdf"); Imports IronPdf Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf") ' Redact 'Alaric' phrase from all pages pdf.RedactTextOnAllPages("Alaric") pdf.SaveAs("redacted.pdf") $vbLabelText $csharpLabel 相關教學:如何將 URL 渲染為 PDF 使用 C# 中的Merge方法合併兩個 PDF 檔案。對任何PdfDocument (無論是新建的還是匯入的)使用ReplaceTextOnAllPages ,將舊文字替換為新文字。 using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>"); string oldText = ".NET6"; string newText = ".NET7"; // Replace text on all pages pdf.ReplaceTextOnAllPages(oldText, newText); pdf.SaveAs("replaceText.pdf"); using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>"); string oldText = ".NET6"; string newText = ".NET7"; // Replace text on all pages pdf.ReplaceTextOnAllPages(oldText, newText); pdf.SaveAs("replaceText.pdf"); Imports IronPdf Private renderer As New ChromePdfRenderer() Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>") Private oldText As String = ".NET6" Private newText As String = ".NET7" ' Replace text on all pages pdf.ReplaceTextOnAllPages(oldText, newText) pdf.SaveAs("replaceText.pdf") $vbLabelText $csharpLabel 相關操作指南文章:如何合併或分割PDF文件 快速故障排除 問題 解決方案 缺少 Visual C++ 運行時 安裝 Visual C++ 可再發行元件套件-Chrome 引擎需要 x86 和 x64 版本。 許可證未識別 使用IronPdf.License.IsLicensed屬性進行驗證。確保在執行任何 IronPDF 操作之前套用許可證。 慢速首次渲染 啟動時呼叫IronPdf.Installation.Initialize()以預初始化渲染引擎 Linux/Docker 依賴項 設定Installation.LinuxAndDockerDependenciesAutoConfig = true以自動安裝依賴項 後續步驟 編輯 PDF 查看功能 組織 PDF 查看功能 簽署並保護 PDF 查看功能 Installation Overview Installation Overview 常見問題解答 我如何設置 IronPdfEngine 以進行遠程 PDF 生成? 要設置 IronPdfEngine 進行遠程 PDF 生成,請從 NuGet 安裝 IronPdf.Slim 包,並使用 IronPdfConnectionConfiguration 類配置連接設置。此設置允許您遠程連接您的應用程序到 IronPdfEngine 實例。 在我的應用程序中使用 IronPdfEngine 的主要好處是什麼? 將 IronPdfEngine 與您的應用程序一起使用允許遠程執行 PDF 任務,幫助避免平台特定的兼容性問題,特別是在較舊的系統和移動平台上。它還消除了執行期間對 .NET 運行時的需求。 為什麼我可能會選擇使用 IronPdfEngine 而不是本機 PDF 庫? 您可能會選擇使用 IronPdfEngine 遠程運行性能密集的 PDF 功能,以減少與不同操作系統的兼容性問題,並通過利用一個 Chrome 相同的渲染器來改善 HTML 到 PDF 轉換的性能。 IronPdfEngine 是否支持橫向擴展? 不,IronPdfEngine 目前不支持橫向擴展,這意味著它不能在多個實例之間進行負載平衡,因為 PDF 文件二進制文件在服務器內存中的處理方式。 IronPdfEngine 能否在不同的操作系統上運行? IronPdfEngine 被設計為使用 Docker 容器運行在 Linux 系統上。然而,這些二進制文件是平台特定的,因此您需要確保您正在使用適合您的操作系統的正確版本。 如果使用 IronPdfEngine 時我的 PDF 輸出不同,我應該怎麼做? 由於不同的操作系統行為,PDF 輸出可能會略有不同。為了盡量減少差異,請確保您使用正確的 Docker 映像,並檢查任何可能影響渲染的操作系統特定設置。 我如何確保我的應用程序使用的是正確版本的 IronPdfEngine? 為確保兼容性,每個版本的IronPDF需要匹配版本的IronPdfEngine。請確保同時更新這兩個組件,以避免跨版本問題。 在 Windows 上使用 IronPdfEngine 有什麼限制? 在 Windows 上使用 IronPdfEngine 時,您需要 Docker 的 Linux 容器,並且必須確保服務器端口可達。這些二進制文件是平台特定的,必須切換到 Linux 容器。 我如何配置 IronPDF 以連接到遠程 IronPdfEngine 服務器? 要配置 IronPDF 遠程服務器,請使用 Installation.ConnectToIronPdfHost,結合 IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer 方法,指定服務器的 IP 和端口詳細信息。 使用 IronPdfEngine 時,應使用哪個包來將應用程序大小降至最低? 您應從 NuGet 使用 IronPdf.Slim 包,因為它只包含運行 IronPDF 與 IronPdfEngine 所需的組件,從而減少應用程序大小。 Curtis Chau 立即與工程團隊聊天 技術撰稿人 Curtis Chau 擁有電腦科學學士學位(卡爾頓大學),專長於前端開發,精通 Node.js、TypeScript、JavaScript 和 React。Curtis 對製作直覺且美觀的使用者介面充滿熱情,他喜歡使用現代化的架構,並製作結構良好且視覺上吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 也有濃厚的興趣,他喜歡探索整合硬體與軟體的創新方式。在空閒時間,他喜歡玩遊戲和建立 Discord bots,將他對技術的熱愛與創意結合。 準備好開始了嗎? Nuget 下載 17,386,124 | 版本: 2026.2 剛剛發布 免費 NuGet 下載 總下載量:17,386,124 查看許可證