IronPDF 開始使用 快速入門 IronPDF Quickstart Guide Curtis Chau 更新日期:7月 12, 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 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++ 可再發佈組件(適用於 Windows)。 2. 安裝 IronPDF 標準的 IronPDF 安裝會在本地運行。 如果您想要部署在 Docker/微服務上,請查看 遠程引擎模式指南。 Get started making PDFs with NuGet now: Install IronPDF with NuGet Package Manager PM > Install-Package IronPdf Copy and run this code snippet. IronPdf.ChromePdfRenderer .StaticRenderHtmlAsPdf("<p>Hello World</p>") .SaveAs("pixelperfect.pdf"); Deploy to test on your live environment Start using IronPDF in your project today with a free trial Free 30 day Trial data-active-tab="1"> class="installation-options__tabs"> data-tab="1"> NuGet Package Manager data-tab="2"> DLL Download data-tab="1"> data-tab="2"> id="nuget-package-manager-start"> Go to the IronPDF NuGet library: 在解決方案資源管理器中,右鍵單擊引用 選擇“管理 NuGet 包”>“瀏覽”>搜尋 IronPdf Install-Package IronPdf id="nuget-package-manager-end"> id="dll-download-start"> 下載 IronPDF DLL package 將 ZIP 文件解壓縮到您的解決方案目錄中的某個位置 在 Visual Studio 解決方案資源管理器中,右鍵單擊“相依性” '添加項目參考' > 選擇“瀏覽”以包括從 zip 中提取的所有 DLL。 class="related-link">相關: 更多配置設置 id="dll-download-end"> 特定平台指南 class="col-2"> class="platform-guide__icon"> class="platform-guide__title">Windows class="col-2"> class="platform-guide__icon"> class="platform-guide__title">Linux class="col-2"> class="platform-guide__icon"> class="platform-guide__title">MacOS class="col-2"> class="platform-guide__icon"> class="platform-guide__title">Docker class="col-2"> class="platform-guide__icon"> class="platform-guide__title">Azure class="col-2"> class="platform-guide__icon"> class="platform-guide__title">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 class="related-link">查看 IronPDF 許可證 4. 創建您的第一個 PDF class="related-link">IronPDF 幫助您創建 PDF 或將 HTML、DOCX、RTF、Markdown 和圖像轉換為具有完全保真度的 PDF。探索更多類型的 PDF 轉換 在您的 .cs 文件頂部添加此內容。 using IronPdf; using IronPdf; Imports IronPdf $vbLabelText $csharpLabel data-active-tab="1"> class="installation-options__tabs"> data-tab="1"> 創建空白 PDF data-tab="2"> 將 HTML 字符串轉換為 PDF data-tab="3"> 將 DOCX 轉換為 PDF data-tab="1"> data-tab="2"> data-tab="3"> id="create-a-blank-pdf-start"> 創建 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"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel id="create-a-blank-pdf-end"> id="convert-html-string-to-pdf-start"> 使用 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"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel class="related-link">相關操作文章: 如何在 C# 中將 HTML 字符串轉換為 PDF id="convert-html-string-to-pdf-end"> id="convert-docx-to-pdf-start"> 使用 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 class="related-link">相關操作文章: 如何在 C# 中將 Microsoft Word 轉換為 PDF id="convert-docx-to-pdf-end"> 5. 更多高級範例 除了簡單的 PDF 創建和轉換,IronPDF 還提供更強大的 PDF 自定義選項。 data-active-tab="1"> class="installation-options__tabs"> data-tab="1"> 添加頁眉和頁腳 data-tab="2"> 編輯文字 data-tab="3"> 合併 PDF data-tab="1"> data-tab="2"> data-tab="3"> id="add-headers-and-footers-start"> 通過實例化 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"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel class="related-link">相關操作文章: 如何添加頁眉和頁腳 id="add-headers-and-footers-end"> id="redact-text-start"> 使用 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 class="related-link">相關操作文章: 如何渲染 URL 為 PDF id="redact-text-end"> id="merge-pdfs-start"> 使用 Merge 方法在 C# 中合併兩個 PDF 文件。 使用 ReplaceTextOnAllPages 將任何新的或導入的 PdfDocument 中的舊文本替換為新文本。 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 class="related-link">相關操作文章: 如何合併或拆分 PDF id="merge-pdfs-end"> 快速故障排除 class="quick-troubleshooting"> 問題 解決方案 缺少 Visual C++ 運行時 安裝 Visual C++ 可再發佈組件 - Chrome 引擎需要 x86 和 x64 版本 許可證無法識別 使用 IronPdf.License.IsLicensed 屬性進行驗證。確保在執行任何 IronPDF 操作之前應用許可證 首次渲染速度慢 在啟動時喚起 IronPdf.Installation.Initialize() 以預初始化渲染引擎 Linux/Docker 依賴 設置 Installation.LinuxAndDockerDependenciesAutoConfig = true 以自動安裝依賴 下一步 class="next-step__card-info"> class="next-step__card-icon"> class="next-step__card-text">編輯 PDF class="next-step__card-cta">查看特點 class="next-step__card-info"> class="next-step__card-icon"> class="next-step__card-text">組織 PDF class="next-step__card-cta">查看特點 class="next-step__card-info"> class="next-step__card-icon"> class="next-step__card-text">簽名和保護 PDF class="next-step__card-cta">查看特點 class="tutorials-navigation"> 安裝概覽 安裝概覽 常見問題解答 如何設定 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包,因為它只包含使用 IronPdfEngine 運行 IronPDF 所需的組件,從而減少應用程式的大小。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 16,133,208 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:16,133,208 查看許可證