MIGRATION GUIDES How to Migrate from GrabzIt to IronPDF in C# Curtis Chau 發表日期:2026年1月25日 下載 IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 從 抓取 遷移到 IronPDF 會將您的 .NET PDF 工作流程從基於雲端的螢幕截圖擷取服務(具有回呼複雜性)轉變為進程內庫,該程式庫可產生具有可選、可搜尋文字的真正向量 PDF。 本指南為專業的 .NET 開發人員提供了一個全面的、逐步的遷移路徑,消除了外部伺服器依賴性、回調處理程序和按捕獲次數計費。 為什麼要從 抓取 遷移到 IronPDF GrabzIt架構問題 GrabzIt 是一款基於雲端的螢幕截圖和 PDF 擷取服務。雖然它便於快速集成,但其架構存在根本性的限制: 1.基於圖像的 PDF: 抓取 創建基於螢幕截圖的 PDF,其中文字不可選——本質上是包裝在 PDF 格式中的圖像。 對於任何需要文字處理或輔助功能的應用場景來說,這是一個根本性的限制。 2.外部處理:所有內容都會傳送到 抓取 的伺服器進行處理-這會對敏感資料造成隱私和合規性的擔憂。 您的HTML內容將離開您的基礎架構。 3.回呼複雜性: 抓取 使用非同步回呼模型,需要 webhook 處理基礎架構。 您必須設定端點來接收結果,這會增加架構的複雜度。 4.按捕獲量定價:按使用量付費模式在規模化時可能會變得很昂貴。 每次產生PDF文件都會產生費用。 5.無法進行文字搜尋:由於 PDF 是基於圖像的,因此如果沒有 OCR,文字搜尋和提取就無法進行——這需要額外的步驟和成本。 6.檔案大小更大:基於圖像的 PDF 文件比基於向量的 PDF 文件大得多,通常是後者的 5-10 倍。 7.網路依賴性:沒有網路連線就無法產生 PDF,因此無法離線使用。 8.延遲:每次產生 PDF 都需要與外部伺服器進行網路往返,增加 500 毫秒至 5 秒的延遲。 抓取 與 IronPDF 對比 方面 抓取 IronPDF PDF類型 基於圖像(螢幕截圖) 真正的向量 PDF 文字選擇 不可能 全文選擇 文字搜尋 需要進行光學字元辨識 (OCR)。 原生可搜尋 處理地點 外部伺服器 本地/進程內 隱私 向外部發送的數據 資料保留在本地 延遲 網路往返時間(500毫秒-5秒) 本地處理(約100毫秒) 定價模式 每次捕獲 按開發者計費的許可 離線能力 不 是的 文件大小 大型(影像資料) 小(向量資料) 需要回調 是的(非同步) 否(同步/非同步) CSS/JS 支持 有限的 全鉻發動機 對於計劃在 2025 年和 2026 年採用 .NET 10 和 C# 14 的團隊,IronPDF 提供了一個面向未來的基礎,其本地處理功能與現代 .NET 模式原生整合。 遷移複雜度評估 各功能預計工作量 特徵 遷移複雜性 筆記 HTML 轉 PDF 非常低 直接替代法 PDF檔案的URL 非常低 直接替代法 HTML轉影像 低的 渲染 PDF 然後轉換 頁面尺寸/頁邊距 低的 屬性映射 回呼處理程序 低的 完全刪除它們 水印 低的 基於HTML的方法 頁首/頁尾 中等的 模板轉 HTML 身份驗證金鑰 非常低 移除 抓取 金鑰 範式轉移 GrabzIt此次遷移的根本轉變在於從非同步回調式雲端處理轉向同步進程內產生: GrabzIt:傳送 HTML → 等待回呼 → 從伺服器檢索結果 IronPDF:渲染 HTML → 立即取得 PDF 開始之前 先決條件 .NET 版本: IronPDF 支援 .NET Framework 4.6.2+ 和 .NET Core 3.1+ / .NET 5/6/7/8/9+ 2.許可證密鑰:從ironpdf.com取得您的 IronPDF 許可證密鑰。 3.規劃基礎設施移除:記錄用於退役的回呼處理程序和 webhook 端點 識別所有 抓取 使用情況 # Find 抓取 client usage grep -r "GrabzItClient\|GrabzIt\." --include="*.cs" . # Find callback handlers grep -r "GrabzIt\|grabzit" --include="*.ashx" --include="*.aspx" --include="*.cs" . # Find configuration grep -r "APPLICATION_KEY\|APPLICATION_SECRET\|grabzit" --include="*.config" --include="*.json" . # Find 抓取 client usage grep -r "GrabzItClient\|GrabzIt\." --include="*.cs" . # Find callback handlers grep -r "GrabzIt\|grabzit" --include="*.ashx" --include="*.aspx" --include="*.cs" . # Find configuration grep -r "APPLICATION_KEY\|APPLICATION_SECRET\|grabzit" --include="*.config" --include="*.json" . SHELL NuGet 套件變更 # Remove GrabzIt dotnet remove package GrabzIt # Install IronPDF dotnet add package IronPdf # Remove GrabzIt dotnet remove package GrabzIt # Install IronPDF dotnet add package IronPdf SHELL 快速入門遷移 步驟 1:更新許可證配置 之前(GrabzIt): GrabzIt 需要為每個客戶端實例設定應用程式金鑰和金鑰: var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); $vbLabelText $csharpLabel (IronPDF 之後): // Set once at application startup IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"; // Then create renderer without credentials var renderer = new ChromePdfRenderer(); // Set once at application startup IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"; // Then create renderer without credentials var renderer = new ChromePdfRenderer(); $vbLabelText $csharpLabel 步驟 2:更新命名空間導入 // Before (GrabzIt) using GrabzIt; using GrabzIt.Parameters; // After (IronPDF) using IronPdf; // Before (GrabzIt) using GrabzIt; using GrabzIt.Parameters; // After (IronPDF) using IronPdf; $vbLabelText $csharpLabel 完整 API 參考 GrabzItClient 到 IronPDF 的映射 抓取 方法 IronPDF當量 筆記 new GrabzItClient(key, secret) new ChromePdfRenderer() 無需身份驗證 HTMLToPDF(html) renderer.RenderHtmlAsPdf(html) 返回 PDF 文件 URLToPDF(url) renderer.RenderUrlAsPdf(url) 返回 PDF 文件 HTMLToImage(html) pdf.ToBitmap() 渲染然後轉換 Save(callbackUrl) pdf.SaveAs(path) 立即見效 SaveTo(filePath) pdf.SaveAs(filePath) 相同的功能 GetResult(id) 不適用 無需回訪 GetStatus(id) 不適用 同步操作 PDF選項到渲染選項的映射 抓取 PDF選項 IronPDF屬性 筆記 PageSize (A4,Letter) RenderingOptions.PaperSize 使用PdfPaperSize枚舉 CustomId 不適用 不需要 MarginTop RenderingOptions.MarginTop 單位相同(毫米) MarginBottom RenderingOptions.MarginBottom 單位相同(毫米) ImageOptions 到 IronPDF 映射 抓取 圖片選項 IronPDF當量 筆記 Format (png、jpg) bitmap.Save(path, ImageFormat.Png) 在ToBitmap()之後 Width RenderingOptions.ViewPortWidth 視窗寬度 Height RenderingOptions.ViewPortHeight 視窗高度 程式碼遷移範例 範例 1:HTML 轉 PDF 之前(GrabzIt): // NuGet: Install-Package GrabzIt using GrabzIt; using GrabzIt.Parameters; using System; class Program { static void Main() { var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var options = new PDFOptions(); options.CustomId = "my-pdf"; grabzIt.HTMLToPDF("<html><body><h1>Hello World</h1></body></html>", options); grabzIt.SaveTo("output.pdf"); } } // NuGet: Install-Package GrabzIt using GrabzIt; using GrabzIt.Parameters; using System; class Program { static void Main() { var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var options = new PDFOptions(); options.CustomId = "my-pdf"; grabzIt.HTMLToPDF("<html><body><h1>Hello World</h1></body></html>", options); grabzIt.SaveTo("output.pdf"); } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1></body></html>"); pdf.SaveAs("output.pdf"); } } // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1></body></html>"); pdf.SaveAs("output.pdf"); } } $vbLabelText $csharpLabel 差異很大:GrabzIt 需要 API 憑證( YOUR_APPLICATION_KEY , YOUR_APPLICATION_SECRET ),建立一個帶有自訂 ID 的PDFOptions對象,結果是透過外部伺服器發送的基於圖像的 PDF。 IronPDF 的ChromePdfRenderer可在本地產生真正的向量 PDF,文字可選擇-無需憑證、無需網路呼叫、無需回呼。 有關其他渲染選項,請參閱HTML 轉 PDF 文件。 範例 2:URL 轉 PDF 之前(GrabzIt): // NuGet: Install-Package GrabzIt using GrabzIt; using GrabzIt.Parameters; using System; class Program { static void Main() { var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var options = new PDFOptions(); options.PageSize = PageSize.A4; grabzIt.URLToPDF("https://www.example.com", options); grabzIt.SaveTo("webpage.pdf"); } } // NuGet: Install-Package GrabzIt using GrabzIt; using GrabzIt.Parameters; using System; class Program { static void Main() { var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var options = new PDFOptions(); options.PageSize = PageSize.A4; grabzIt.URLToPDF("https://www.example.com", options); grabzIt.SaveTo("webpage.pdf"); } } $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("webpage.pdf"); } } // 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("webpage.pdf"); } } $vbLabelText $csharpLabel GrabzIt 需要透過選項物件配置PageSize.A4並與外部伺服器進行驗證。 IronPDF 的RenderUrlAsPdf()方法直接接受 URL,並使用完整的 Chromium 引擎在本地渲染它,並完全支援 CSS 和 JavaScript。 了解更多關於URL轉PDF的資訊。 範例 3:HTML 轉影像 之前(GrabzIt): // NuGet: Install-Package GrabzIt using GrabzIt; using GrabzIt.Parameters; using System; class Program { static void Main() { var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var options = new ImageOptions(); options.Format = ImageFormat.png; options.Width = 800; options.Height = 600; grabzIt.HTMLToImage("<html><body><h1>Hello World</h1></body></html>", options); grabzIt.SaveTo("output.png"); } } // NuGet: Install-Package GrabzIt using GrabzIt; using GrabzIt.Parameters; using System; class Program { static void Main() { var grabzIt = new GrabzItClient("YOUR_APPLICATION_KEY", "YOUR_APPLICATION_SECRET"); var options = new ImageOptions(); options.Format = ImageFormat.png; options.Width = 800; options.Height = 600; grabzIt.HTMLToImage("<html><body><h1>Hello World</h1></body></html>", options); grabzIt.SaveTo("output.png"); } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; using System; using System.Drawing; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1></body></html>"); var images = pdf.ToBitmap(); images[0].Save("output.png", System.Drawing.Imaging.ImageFormat.Png); } } // NuGet: Install-Package IronPdf using IronPdf; using System; using System.Drawing; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1></body></html>"); var images = pdf.ToBitmap(); images[0].Save("output.png", System.Drawing.Imaging.ImageFormat.Png); } } $vbLabelText $csharpLabel GrabzIt 提供了一個專用的HTMLToImage()方法,帶有ImageOptions ,用於配置格式、寬度和高度。 IronPDF 首先使用RenderHtmlAsPdf()將 HTML 渲染為 PDF,然後使用ToBitmap()轉換為點陣圖,達到相同的效果。 這種方法可以透過一次渲染操作同時產生 PDF 和影像輸出。 關鍵遷移說明 無需回撥電話 最重要的架構變化是完全取消回呼處理程序: // GrabzIt: Async callback pattern grabzIt.HTMLToPDF(html, options); grabzIt.Save("https://myserver.com/grabzit-callback"); // Wait for callback... // Callback handler (separate endpoint) public class GrabzItHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string id = context.Request.QueryString["id"]; GrabzItClient grabzIt = new GrabzItClient("APP_KEY", "APP_SECRET"); GrabzItFile file = grabzIt.GetResult(id); file.Save("output.pdf"); } } // IronPDF: Synchronous - result immediately available var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); // Done! 不 callback needed. // GrabzIt: Async callback pattern grabzIt.HTMLToPDF(html, options); grabzIt.Save("https://myserver.com/grabzit-callback"); // Wait for callback... // Callback handler (separate endpoint) public class GrabzItHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string id = context.Request.QueryString["id"]; GrabzItClient grabzIt = new GrabzItClient("APP_KEY", "APP_SECRET"); GrabzItFile file = grabzIt.GetResult(id); file.Save("output.pdf"); } } // IronPDF: Synchronous - result immediately available var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); // Done! 不 callback needed. $vbLabelText $csharpLabel 遷移後刪除所有 抓取 回呼處理程序( .ashx檔案、處理程序端點、webhook 設定)。 真正的向量PDF GrabzIt 創建的是基於圖像的 PDF,其中的文字不可選。 IronPDF 產生真正的向量 PDF: // With IronPDF, text extraction works natively var pdf = PdfDocument.FromFile("document.pdf"); string text = pdf.ExtractAllText(); // Works without OCR! // With IronPDF, text extraction works natively var pdf = PdfDocument.FromFile("document.pdf"); string text = pdf.ExtractAllText(); // Works without OCR! $vbLabelText $csharpLabel 更多詳情請參閱文字擷取文件。 文件體積更小 基於向量的 PDF 檔案通常比 抓取 基於圖像的 PDF 檔案小 5-10 倍。 這可以降低儲存成本,縮短下載時間,並提高電子郵件附件的可行性。 移除 API 憑證 GrabzIt 每次操作都需要 API 憑證: // Remove these from configuration // YOUR_APPLICATION_KEY // YOUR_APPLICATION_SECRET // Remove these from configuration // YOUR_APPLICATION_KEY // YOUR_APPLICATION_SECRET $vbLabelText $csharpLabel IronPDF 使用在應用程式啟動時一次性設定的單一許可證金鑰——無需按請求進行身份驗證。 故障排除 問題 1:未找到 GrabzItClient 問題:移除 抓取 後, GrabzItClient引用導致編譯錯誤。 解決方案:替換為ChromePdfRenderer : // Remove: // var grabzIt = new GrabzItClient("KEY", "SECRET"); // Replace with: var renderer = new ChromePdfRenderer(); // Remove: // var grabzIt = new GrabzItClient("KEY", "SECRET"); // Replace with: var renderer = new ChromePdfRenderer(); $vbLabelText $csharpLabel 問題 2:未找到 PDFOptions 問題: IronPDF 中不存在PDFOptions類。 解決方案:使用RenderingOptions屬性: // GrabzIt var options = new PDFOptions(); options.PageSize = PageSize.A4; // IronPDF renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; // GrabzIt var options = new PDFOptions(); options.PageSize = PageSize.A4; // IronPDF renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; $vbLabelText $csharpLabel 問題 3:回呼處理程序仍然被引用 問題:應用程式需要回調端點。 解決方案:徹底刪除回呼機制。 IronPDF 同步回傳結果-無需 webhook。 問題 4:未找到 ImageOptions 問題: IronPDF 中不存在ImageOptions類別。 解決方案:先渲染成 PDF,再轉換: // GrabzIt var options = new ImageOptions(); options.Format = ImageFormat.png; grabzIt.HTMLToImage(html, options); // IronPDF var pdf = renderer.RenderHtmlAsPdf(html); var images = pdf.ToBitmap(); images[0].Save("output.png", System.Drawing.Imaging.ImageFormat.Png); // GrabzIt var options = new ImageOptions(); options.Format = ImageFormat.png; grabzIt.HTMLToImage(html, options); // IronPDF var pdf = renderer.RenderHtmlAsPdf(html); var images = pdf.ToBitmap(); images[0].Save("output.png", System.Drawing.Imaging.ImageFormat.Png); $vbLabelText $csharpLabel 遷移清單 遷移前 清點程式碼庫中所有 抓取 API 呼叫 確定回呼處理程序和 webhook 端點 記錄 抓取 目前的選項和模板 取得 IronPDF 許可證密鑰 計劃回調處理程序停用 程式碼遷移 安裝 IronPdf NuGet 套件: dotnet add package IronPdf 移除 抓取 NuGet 套件: dotnet remove package GrabzIt 將GrabzItClient替換為ChromePdfRenderer 將HTMLToPDF()轉換為RenderHtmlAsPdf() 將URLToPDF()轉換為RenderUrlAsPdf() 將Save(callback)替換為SaveAs(path) 將選項從PDFOptions更新為RenderingOptions 基礎設施遷移 刪除回呼處理程序檔案( .ashx等) 從設定中移除 抓取 API 金鑰 移除 webhook URL 配置 將 IronPDF 許可證金鑰新增至配置中 移除輪詢/狀態檢查代碼 測試 測試 HTML 到 PDF 的轉換 測試 URL 到 PDF 的轉換 確認輸出的PDF文件中文字可選擇。 測試文字擷取功能(不使用 OCR) 確認檔案大小較小 無網路延遲的效能測試 移民後 取消 抓取 訂閱 歸檔回呼處理程序程式碼 更新文檔 監控任何與 抓取 相關的錯誤 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 HiQPdf to IronPDF in C#How to Migrate from Gotenberg to Ir...
發表日期 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. 閱讀更多