MIGRATION GUIDES How to Migrate from SelectPdf to IronPDF in C# Curtis Chau 發表日期:2026年2月1日 下載 IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 從 選擇PDF 遷移到 IronPDF 會將您的 PDF 生成工作流程從僅限 Windows 的解決方案(使用過時的渲染引擎)轉變為具有完整 CSS3 和 JavaScript 支援的現代化跨平台庫。 本指南提供了完整的逐步遷移路徑,使用戶能夠部署到 Linux、Docker、Azure Functions 以及 選擇PDF 不支援的其他雲端平台。 為什麼要從 SelectPDF 遷移到 IronPDF 了解 SelectPDF SelectPdf 是一個商業庫,旨在用 C# 將 HTML 內容轉換為 PDF。 該程式庫專為需要在應用程式中無縫整合 PDF 生成功能的開發人員而設計。 選擇PDF 的優點在於其簡單的 API,這使其成為 PDF 生成新手的理想選擇。 但是,潛在用戶必須意識到它的關鍵限制。 儘管宣稱具備跨平台功能,但SelectPdf實際上只能在Windows環境下運作。 這在考慮基於雲端的部署解決方案(例如 Azure Functions 或 Docker 等容器)時構成了相當大的障礙。 此外,其免費版本功能非常有限,最多只能顯示五頁,之後就會自動添加浮水印。 選擇PDF 利用了過時的 Blink 分支和基於 WebKit 的架構,這導致與 CSS Grid 和高級 flexbox 等現代 Web 技術存在相容性問題。 選擇PDF 的關鍵局限性 問題 影響 IronPDF解決方案 僅限 Windows 系統 無法部署到 Linux、Docker 和 Azure Functions。 完全跨平台支援 過時的渲染引擎 現代 CSS 失效,佈局崩潰 最新的鉻 免費版限5頁 5頁後開始添加強力浮水印 慷慨的試用期 不支援 .NET 10 面向未來的問題 完全支援 .NET 10 雲端部署受阻 無法使用 AWS Lambda 和 Azure Functions 雲端原生 SelectPDF 與 IronPDF 的比較 特徵 選擇PDF IronPDF 平台支援 僅限 Windows 系統 完全跨平台,支援 10 多個發行版 支援現代 Web 標準 限量(過時的 Blink) 完整的 CSS3,現代 Chromium 免費版頁面最大限制 5頁 靈活,無硬性限制 定價 起價 499 美元 透明且彈性的定價 .NET 10 支持 沒有任何 全力支持 雲端環境部署 不支援。 完全支持 CSS Grid 有限的 全力支持 Flexbox 有限的 全力支持 CSS變數 不支援 全力支持 Docker 不支援 官方圖片 Azure Functions 不支援 全力支持 AWS Lambda 不支援 全力支持 對於計劃在 2025 年和 2026 年採用 .NET 10 和 C# 14 的團隊來說,SelectPdf 明確不支援 .NET 10,這造成了未來相容性問題。 IronPDF 為所有現代 .NET 版本提供全面支援。 開始之前 先決條件 .NET 環境: .NET Framework 4.6.2+ 或 .NET Core 3.1+ / .NET 5/6/7/8/9/10+ NuGet 存取權限:能夠安裝 NuGet 套件 IronPDF 許可證:請從ironpdf.com取得您的許可證密鑰。 NuGet 套件變更 # Remove SelectPdf dotnet remove package Select.HtmlToPdf # Install IronPDF dotnet add package IronPdf # Remove SelectPdf dotnet remove package Select.HtmlToPdf # Install IronPDF dotnet add package IronPdf SHELL 許可證配置 // Add at application startup IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"; // Add at application startup IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"; $vbLabelText $csharpLabel 完整 API 參考 命名空間變更 // Before: SelectPdf using SelectPdf; // After: IronPDF using IronPdf; using IronPdf.Engines.Chrome; // Before: SelectPdf using SelectPdf; // After: IronPDF using IronPdf; using IronPdf.Engines.Chrome; $vbLabelText $csharpLabel 核心 API 映射 選擇PDF IronPDF 筆記 HtmlToPdf ChromePdfRenderer 核心轉換器類 converter.ConvertHtmlString(html) renderer.RenderHtmlAsPdf(html) HTML字串轉換 converter.ConvertUrl(url) renderer.RenderUrlAsPdf(url) URL轉換 doc.Save(path) pdf.SaveAs(path) 儲存到文件 doc.Close() 不需要 IronPDF負責清理工作 converter.Options.PdfPageSize renderer.RenderingOptions.PaperSize 紙張尺寸 converter.Options.PdfPageOrientation renderer.RenderingOptions.PaperOrientation 方向 converter.Options.MarginTop renderer.RenderingOptions.MarginTop 最高利潤率 converter.Options.MarginBottom renderer.RenderingOptions.MarginBottom 底邊 converter.Options.MarginLeft renderer.RenderingOptions.MarginLeft 左邊距 converter.Options.MarginRight renderer.RenderingOptions.MarginRight 右側邊距 PdfPageSize.A4 PdfPaperSize.A4 A4 尺寸枚舉 PdfPageOrientation.Portrait PdfPaperOrientation.Portrait 肖像枚舉 PdfPageOrientation.Landscape PdfPaperOrientation.Landscape 景觀枚舉 {page_number} {page} 頁碼佔位符 {total_pages} {total-pages} 總頁數佔位符 程式碼遷移範例 範例 1:HTML 字串到 PDF 的轉換 之前(SelectPdf): // NuGet: Install-Package Select.HtmlToPdf using SelectPdf; using System; class Program { static void Main() { string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; HtmlToPdf converter = new HtmlToPdf(); PdfDocument doc = converter.ConvertHtmlString(htmlContent); doc.Save("document.pdf"); doc.Close(); Console.WriteLine("PDF generated from HTML string"); } } // NuGet: Install-Package Select.HtmlToPdf using SelectPdf; using System; class Program { static void Main() { string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; HtmlToPdf converter = new HtmlToPdf(); PdfDocument doc = converter.ConvertHtmlString(htmlContent); doc.Save("document.pdf"); doc.Close(); Console.WriteLine("PDF generated from HTML string"); } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(htmlContent); pdf.SaveAs("document.pdf"); Console.WriteLine("PDF generated from HTML string"); } } // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(htmlContent); pdf.SaveAs("document.pdf"); Console.WriteLine("PDF generated from HTML string"); } } $vbLabelText $csharpLabel 此範例示範了核心 API 的差異。 選擇PDF 使用HtmlToPdf作為轉換器類,呼叫ConvertHtmlString()建立一個PdfDocument ,然後呼叫Save()和Close()來持久化和清理。 IronPDF 使用ChromePdfRenderer和RenderHtmlAsPdf() ,傳回一個PdfDocument ,然後使用SaveAs()儲存。 無需呼叫Close()函數-IronPDF 會自動處理資源管理。 請參閱HTML 轉 PDF 文件以取得完整範例。 範例 2:URL 轉 PDF 之前(SelectPdf): // NuGet: Install-Package Select.HtmlToPdf using SelectPdf; using System; class Program { static void Main() { HtmlToPdf converter = new HtmlToPdf(); PdfDocument doc = converter.ConvertUrl("https://www.example.com"); doc.Save("output.pdf"); doc.Close(); Console.WriteLine("PDF created successfully"); } } // NuGet: Install-Package Select.HtmlToPdf using SelectPdf; using System; class Program { static void Main() { HtmlToPdf converter = new HtmlToPdf(); PdfDocument doc = converter.ConvertUrl("https://www.example.com"); doc.Save("output.pdf"); doc.Close(); Console.WriteLine("PDF created successfully"); } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.example.com"); pdf.SaveAs("output.pdf"); Console.WriteLine("PDF created successfully"); } } // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.example.com"); pdf.SaveAs("output.pdf"); Console.WriteLine("PDF created successfully"); } } $vbLabelText $csharpLabel SelectPdf 的ConvertUrl()方法直接對應到 IronPDF 的RenderUrlAsPdf() 。 關鍵差異在於渲染引擎:SelectPdf 使用的是過時的 Blink/WebKit 分支,難以相容於現代 CSS,而 IronPDF 使用的是最新的穩定版 Chromium,可完全支援 CSS3 和 JavaScript。 了解更多信息,請閱讀我們的教程。 範例 3:自訂頁面設定和邊距 之前(SelectPdf): // NuGet: Install-Package Select.HtmlToPdf using SelectPdf; using System; class Program { static void Main() { HtmlToPdf converter = new HtmlToPdf(); converter.Options.PdfPageSize = PdfPageSize.A4; converter.Options.PdfPageOrientation = PdfPageOrientation.Portrait; converter.Options.MarginTop = 20; converter.Options.MarginBottom = 20; converter.Options.MarginLeft = 20; converter.Options.MarginRight = 20; string html = "<html><body><h1>Custom Page Settings</h1></body></html>"; PdfDocument doc = converter.ConvertHtmlString(html); doc.Save("custom-settings.pdf"); doc.Close(); Console.WriteLine("PDF with custom settings created"); } } // NuGet: Install-Package Select.HtmlToPdf using SelectPdf; using System; class Program { static void Main() { HtmlToPdf converter = new HtmlToPdf(); converter.Options.PdfPageSize = PdfPageSize.A4; converter.Options.PdfPageOrientation = PdfPageOrientation.Portrait; converter.Options.MarginTop = 20; converter.Options.MarginBottom = 20; converter.Options.MarginLeft = 20; converter.Options.MarginRight = 20; string html = "<html><body><h1>Custom Page Settings</h1></body></html>"; PdfDocument doc = converter.ConvertHtmlString(html); doc.Save("custom-settings.pdf"); doc.Close(); Console.WriteLine("PDF with custom settings created"); } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; using IronPdf.Engines.Chrome; using System; class Program { static void Main() { var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait; renderer.RenderingOptions.MarginTop = 20; renderer.RenderingOptions.MarginBottom = 20; renderer.RenderingOptions.MarginLeft = 20; renderer.RenderingOptions.MarginRight = 20; string html = "<html><body><h1>Custom Page Settings</h1></body></html>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("custom-settings.pdf"); Console.WriteLine("PDF with custom settings created"); } } // NuGet: Install-Package IronPdf using IronPdf; using IronPdf.Engines.Chrome; using System; class Program { static void Main() { var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Portrait; renderer.RenderingOptions.MarginTop = 20; renderer.RenderingOptions.MarginBottom = 20; renderer.RenderingOptions.MarginLeft = 20; renderer.RenderingOptions.MarginRight = 20; string html = "<html><body><h1>Custom Page Settings</h1></body></html>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("custom-settings.pdf"); Console.WriteLine("PDF with custom settings created"); } } $vbLabelText $csharpLabel 頁面設定模式幾乎完全相同,只是屬性名稱略有不同: converter.Options.PdfPageSize → renderer.RenderingOptions.PaperSize converter.Options.PdfPageOrientation → renderer.RenderingOptions.PaperOrientation PdfPageSize.A4 → PdfPaperSize.A4 PdfPageOrientation.Portrait → PdfPaperOrientation.Portrait 邊距屬性保持相同的名稱和單位。 僅限 Windows 系統的問題 SelectPdf的平台限制 儘管有各種行銷宣傳,但SelectPdf明確表示不支持: Linux(任何發行版) macOS Docker容器 Azure Functions AWS Lambda Google Cloud Functions 任何基於 ARM 的系統 這是一個根本性的架構限制-SelectPdf 依賴 Windows 特有的函式庫,無法移植。 平台支援對比 平台 選擇PDF IronPDF Windows Server 2019+ ✅ ✅ Windows 10/11 ✅ ✅ Ubuntu 20.04+ ❌ ✅ Debian 10+ ❌ ✅ CentOS 7+ ❌ ✅ Alpine Linux ❌ ✅ Amazon Linux 2 ❌ ✅ macOS 10.15 及更高版本 ❌ ✅ Azure 應用程式服務(Linux) ❌ ✅ Azure Functions ❌ ✅ AWS Lambda ❌ ✅ Docker(Linux) ❌ ✅ Kubernetes ❌ ✅ 過時的渲染引擎 CSS 功能支援比較 SelectPdf 使用的是過時的 Blink/WebKit 分支版本,該版本已未能跟上現代 Web 標準的步伐: CSS 特性 選擇PDF IronPDF CSS Grid ⚠️ 部分/破損 ✅ 已完成 Flexbox(基礎版) ✅ ✅ Flexbox(間隙屬性) ❌ ✅ CSS變數 ❌ ✅ CSS calc() ⚠️ 有限 ✅ @媒體印刷 ⚠️ 有限 ✅ @font-face ⚠️ 有限 ✅ 網頁字體 ⚠️ 有限 ✅ SVG ⚠️ 基本款 ✅ 已完成 CSS轉換 ⚠️ 有限 ✅ CSS動畫 ❌ ✅ 遷移後的新功能 遷移到 IronPDF 後,您將獲得 選擇PDF 無法提供的功能: 跨平台部署 // ✅ IronPDF - Works everywhere using IronPdf; // Azure 應用程式服務(Linux) - WORKS // Docker container - WORKS // AWS Lambda - WORKS // GitHub Actions on ubuntu-latest - WORKS // macOS development - WORKS var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Hello</h1>"); pdf.SaveAs("output.pdf"); // ✅ IronPDF - Works everywhere using IronPdf; // Azure 應用程式服務(Linux) - WORKS // Docker container - WORKS // AWS Lambda - WORKS // GitHub Actions on ubuntu-latest - WORKS // macOS development - WORKS var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Hello</h1>"); pdf.SaveAs("output.pdf"); $vbLabelText $csharpLabel 現代 CSS 支持 // ✅ IronPDF - Uses latest stable Chromium var renderer = new ChromePdfRenderer(); var html = @" <style> :root { --primary: #007bff; --gap: 20px; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); } </style> <div class='grid'> <div style='background: var(--primary); color: white; padding: 1rem;'>Item 1</div> <div style='background: var(--primary); color: white; padding: 1rem;'>Item 2</div> <div style='background: var(--primary); color: white; padding: 1rem;'>Item 3</div> </div>"; var pdf = renderer.RenderHtmlAsPdf(html); // All modern CSS features render correctly! // ✅ IronPDF - Uses latest stable Chromium var renderer = new ChromePdfRenderer(); var html = @" <style> :root { --primary: #007bff; --gap: 20px; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); } </style> <div class='grid'> <div style='background: var(--primary); color: white; padding: 1rem;'>Item 1</div> <div style='background: var(--primary); color: white; padding: 1rem;'>Item 2</div> <div style='background: var(--primary); color: white; padding: 1rem;'>Item 3</div> </div>"; var pdf = renderer.RenderHtmlAsPdf(html); // All modern CSS features render correctly! $vbLabelText $csharpLabel 無需關閉() IronPDF 可自動處理資源管理: // Option 1: Let garbage collection handle it var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); // No Close() needed // Option 2: Explicit disposal using (var pdf = renderer.RenderHtmlAsPdf(html)) { pdf.SaveAs("output.pdf"); } // Option 1: Let garbage collection handle it var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); // No Close() needed // Option 2: Explicit disposal using (var pdf = renderer.RenderHtmlAsPdf(html)) { pdf.SaveAs("output.pdf"); } $vbLabelText $csharpLabel 遷移清單 遷移前 審核程式碼庫中所有 選擇PDF 的使用情況 記錄目前轉換器選項的映射 確定頁首/頁尾的實作方式 檢查頁碼佔位符語法( {page_number} → {page} ) 注意基本 URL 處理模式 驗證目標部署平台 從ironpdf.com取得 IronPDF 許可證金鑰 程式碼更新 刪除Select.HtmlToPdf NuGet 套件 安裝IronPdf NuGet 套件 更新命名空間導入( using SelectPdf; → using IronPdf; ) 將HtmlToPdf替換為ChromePdfRenderer 將ConvertHtmlString()替換為RenderHtmlAsPdf() 將ConvertUrl()替換為RenderUrlAsPdf() 更新選項屬性名稱( Options.PdfPageSize → RenderingOptions.PaperSize ) 將PdfPageSize轉換為PdfPaperSize 將PdfPageOrientation轉換為PdfPaperOrientation 將doc.Save()替換為pdf.SaveAs() 刪除所有doc.Close()調用 修正頁碼佔位符( {page_number} → {page} , {total_pages} → {total-pages} ) 在應用程式啟動時新增許可證初始化 移民後 執行所有單元測試 驗證 CSS 渲染效果(尤其是 Grid/Flexbox 佈局) 測試 JavaScript 執行 核對頁首/頁尾頁碼 在目標平台(Linux、Docker 等)上進行測試 效能測試 比較 PDF 輸出質量 更新 CI/CD 管線 測試雲端部署(如適用) Curtis Chau 立即與工程團隊聊天 技術撰稿人 Curtis Chau 擁有電腦科學學士學位(卡爾頓大學),專長於前端開發,精通 Node.js、TypeScript、JavaScript 和 React。Curtis 對製作直覺且美觀的使用者介面充滿熱情,他喜歡使用現代化的架構,並製作結構良好且視覺上吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 也有濃厚的興趣,他喜歡探索整合硬體與軟體的創新方式。在空閒時間,他喜歡玩遊戲和建立 Discord bots,將他對技術的熱愛與創意結合。 相關文章 發表日期 2026年2月1日 How to Migrate from ZetPDF to IronPDF in C# Master the migration from ZetPDF to IronPDF with this complete C# guide. Switch from a coordinate-based library to a modern HTML-to-PDF solution. Includes code examples for HTML conversion, merging PDFs, and removing PDFSharp dependencies. 閱讀更多 發表日期 2026年2月1日 How to Migrate from Scryber.Core to IronPDF in C# Master the migration from Scryber.Core to IronPDF with this complete C# guide. Switch from custom XML/HTML parsing to a modern Chromium renderer. Includes code examples for HTML conversion, URL rendering, and replacing proprietary bindings. 閱讀更多 發表日期 2026年2月1日 How to Migrate from XFINIUM.PDF to IronPDF in C# Master the migration from XFINIUM.PDF to IronPDF with this complete C# guide. Switch from manual coordinate-based positioning to declarative HTML/CSS rendering. Includes code examples for replacing graphics primitives and automatic layout. 閱讀更多 How to Migrate from Spire.PDF to IronPDF in C#How to Migrate from Scryber.Core to...
發表日期 2026年2月1日 How to Migrate from ZetPDF to IronPDF in C# Master the migration from ZetPDF to IronPDF with this complete C# guide. Switch from a coordinate-based library to a modern HTML-to-PDF solution. Includes code examples for HTML conversion, merging PDFs, and removing PDFSharp dependencies. 閱讀更多
發表日期 2026年2月1日 How to Migrate from Scryber.Core to IronPDF in C# Master the migration from Scryber.Core to IronPDF with this complete C# guide. Switch from custom XML/HTML parsing to a modern Chromium renderer. Includes code examples for HTML conversion, URL rendering, and replacing proprietary bindings. 閱讀更多
發表日期 2026年2月1日 How to Migrate from XFINIUM.PDF to IronPDF in C# Master the migration from XFINIUM.PDF to IronPDF with this complete C# guide. Switch from manual coordinate-based positioning to declarative HTML/CSS rendering. Includes code examples for replacing graphics primitives and automatic layout. 閱讀更多