MIGRATION GUIDES How to Migrate from Aspose.PDF to IronPDF in C# Curtis Chau 發表日期:2026年1月11日 下載 IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 為什麼要放棄 Aspose.PDF? 雖然 Aspose.PDF 提供了企業級功能,但多種因素促使開發團隊尋求更現代化的替代方案來滿足其 PDF 生成需求。 成本比較 Aspose.PDF 採用傳統的企業授權模式,每年續費,費用會隨著時間的推移而大幅累積: 方面 Aspose.PDF IronPDF 起價 每位開發商每年 1,199 美元 一次性支付 749 美元(精簡版) 許可模式 年度訂閱 + 續費 永久許可 OEM 許可 5,997 美元 + 額外費用 包含在更高層級中 支援 額外費用等級 包括 三年總成本 每位開發商 3,597 美元以上 一次性支付 749 美元 HTML渲染引擎比較 Aspose.PDF 使用的是 Flying Saucer CSS 引擎,難以相容於現代 Web 標準。 IronPDF 利用了完整的 Chromium 渲染引擎: 特徵 Aspose.PDF(飛碟) IronPDF(鉻) CSS3 支持 有限(舊版 CSS) 完整的 CSS3 Flexbox/Grid 不支援 全力支持 JavaScript 非常有限 全力支持 網頁字體 部分的 完全的 現代 HTML5 有限的 完全的 渲染品質 多變的 像素級完美 已記錄的效能問題 使用者反映這兩個庫的效能有顯著差異: 指標 Aspose.PDF IronPDF HTML渲染 有記錄的運行速度下降(某些情況下速度下降了30倍) 優化的鉻引擎 大型文檔 報告的記憶體問題 高效能串流媒體 Linux 效能 CPU佔用率高,並報告有記憶體洩漏 穩定的 Aspose.PDF 與 IronPDF:主要區別 方面 Aspose.PDF IronPDF 定價 1199美元/開發者/年(訂閱) 一次性支付 749 美元(精簡版) HTML引擎 飛碟(有限的 CSS) Chromium(完整 CSS3/JS) 表現 有記錄的放緩 最佳化 許可模式 年度續費 + .lic 文件 永久密鑰 + 基於代碼的密鑰 Linux 支援 已報告的問題(CPU、記憶體) 穩定的 頁面索引 基於 1 的( Pages[1] ) 基於 0 的( Pages[0] ) 遷移前準備 先決條件 請確保您的環境符合以下要求: .NET Framework 4.6.2+ 或 .NET Core 3.1 / .NET 5-9 Visual Studio 2019+ 或帶有 C# 擴充功能的 VS Code NuGet 套件管理器訪問 IronPDF 許可證金鑰(可在ironpdf.com提供免費試用) Aspose.PDF 使用情況審計 在解決方案目錄中執行以下命令,以識別所有 Aspose.PDF 引用: # Find all Aspose.Pdf using statements grep -r "using Aspose.Pdf" --include="*.cs" . # Find HtmlLoadOptions usage grep -r "HtmlLoadOptions\|HtmlFragment" --include="*.cs" . # Find Facades usage grep -r "PdfFileEditor\|PdfFileMend\|PdfFileStamp" --include="*.cs" . # Find TextAbsorber usage grep -r "TextAbsorber\|TextFragmentAbsorber" --include="*.cs" . # Find all Aspose.Pdf using statements grep -r "using Aspose.Pdf" --include="*.cs" . # Find HtmlLoadOptions usage grep -r "HtmlLoadOptions\|HtmlFragment" --include="*.cs" . # Find Facades usage grep -r "PdfFileEditor\|PdfFileMend\|PdfFileStamp" --include="*.cs" . # Find TextAbsorber usage grep -r "TextAbsorber\|TextFragmentAbsorber" --include="*.cs" . SHELL 需要預見的重大變化 Aspose.PDF 模式 需要更改 new Document() + Pages.Add() 改用 HTML 渲染 HtmlLoadOptions ChromePdfRenderer.RenderHtmlAsPdf() TextFragment + 手動定位 基於 CSS 的定位 PdfFileEditor.Concatenate() PdfDocument.Merge() TextFragmentAbsorber pdf.ExtractAllText() ImageStamp 基於HTML的浮水印 .lic文件許可 基於程式碼的許可證密鑰 基於 1 的頁面索引 基於 0 的頁面索引 逐步遷移過程 步驟 1:更新 NuGet 套件 卸載 Aspose.PDF 並安裝 IronPDF: # Remove Aspose.PDF dotnet remove package Aspose.PDF # Install IronPDF dotnet add package IronPdf # Remove Aspose.PDF dotnet remove package Aspose.PDF # Install IronPDF dotnet add package IronPdf SHELL 或透過軟體包管理器控制台: Uninstall-Package Aspose.PDF Install-Package IronPdf 步驟 2:更新命名空間引用 將 Aspose.PDF 命名空間替換為 IronPDF: // Remove these using Aspose.Pdf; using Aspose.Pdf.Text; using Aspose.Pdf.Facades; using Aspose.Pdf.Generator; // Add these using IronPdf; using IronPdf.Rendering; using IronPdf.Editing; // Remove these using Aspose.Pdf; using Aspose.Pdf.Text; using Aspose.Pdf.Facades; using Aspose.Pdf.Generator; // Add these using IronPdf; using IronPdf.Rendering; using IronPdf.Editing; $vbLabelText $csharpLabel 步驟 3:更新許可證配置 Aspose.PDF 使用 .lic 檔案許可。 IronPDF 使用簡單的基於程式碼的金鑰。 Aspose.PDF 實作: var license = new Aspose.Pdf.License(); license.SetLicense("Aspose.Pdf.lic"); var license = new Aspose.Pdf.License(); license.SetLicense("Aspose.Pdf.lic"); $vbLabelText $csharpLabel IronPDF實現: IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"; IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"; $vbLabelText $csharpLabel 完整的 API 遷移參考 核心類別映射 Aspose.PDF 類 IronPDF當量 筆記 Document PdfDocument 主文檔類 HtmlLoadOptions ChromePdfRenderer HTML 轉 PDF TextFragmentAbsorber PdfDocument.ExtractAllText() 文字擷取 PdfFileEditor PdfDocument.Merge() 合併/拆分操作 TextStamp / ImageStamp PdfDocument.ApplyWatermark() 水印 License IronPdf.License 授權 文檔操作 Aspose.PDF 方法 IronPDF 方法 筆記 new Document() new PdfDocument() 空白文檔 new Document(path) PdfDocument.FromFile(path) 從檔案載入 doc.Save(path) pdf.SaveAs(path) 儲存到文件 doc.Pages.Count pdf.PageCount 頁數 doc.Pages.Delete(index) pdf.RemovePage(index) 移除頁面 HTML 轉 PDF Aspose.PDF 方法 IronPDF 方法 筆記 new HtmlLoadOptions() new ChromePdfRenderer() HTML渲染器 new Document(stream, htmlOptions) renderer.RenderHtmlAsPdf(html) HTML字串 new Document(path, htmlOptions) renderer.RenderHtmlFileAsPdf(path) HTML 文件 程式碼遷移範例 轉換為 PDF 的 HTML 字串 Aspose.PDF 最常見的操作體現了方法上的根本區別——Aspose.PDF 需要將 HTML 包裝在 MemoryStream 中,而 IronPDF 則直接接受字串。 Aspose.PDF 實作: // NuGet: Install-Package Aspose.PDF using Aspose.Pdf; using System; using System.IO; using System.Text; class Program { static void Main() { string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML string.</p></body></html>"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(htmlContent))) { var htmlLoadOptions = new HtmlLoadOptions(); var document = new Document(stream, htmlLoadOptions); document.Save("output.pdf"); } Console.WriteLine("PDF created from HTML string"); } } // NuGet: Install-Package Aspose.PDF using Aspose.Pdf; using System; using System.IO; using System.Text; class Program { static void Main() { string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML string.</p></body></html>"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(htmlContent))) { var htmlLoadOptions = new HtmlLoadOptions(); var document = new Document(stream, htmlLoadOptions); document.Save("output.pdf"); } Console.WriteLine("PDF created 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 from HTML string.</p></body></html>"; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(htmlContent); pdf.SaveAs("output.pdf"); Console.WriteLine("PDF created 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 from HTML string.</p></body></html>"; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(htmlContent); pdf.SaveAs("output.pdf"); Console.WriteLine("PDF created from HTML string"); } } $vbLabelText $csharpLabel IronPDF 完全消除了 MemoryStream 封裝——提供了一個更簡潔、更直覺的 API。 HTML 檔案轉 PDF Aspose.PDF 實作: // NuGet: Install-Package Aspose.PDF using Aspose.Pdf; using System; class Program { static void Main() { var htmlLoadOptions = new HtmlLoadOptions(); var document = new Document("input.html", htmlLoadOptions); document.Save("output.pdf"); Console.WriteLine("PDF created successfully"); } } // NuGet: Install-Package Aspose.PDF using Aspose.Pdf; using System; class Program { static void Main() { var htmlLoadOptions = new HtmlLoadOptions(); var document = new Document("input.html", htmlLoadOptions); document.Save("output.pdf"); 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.RenderHtmlFileAsPdf("input.html"); 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.RenderHtmlFileAsPdf("input.html"); pdf.SaveAs("output.pdf"); Console.WriteLine("PDF created successfully"); } } $vbLabelText $csharpLabel 合併多個PDF文件 Aspose.PDF 需要手動遍歷頁面。 IronPDF 提供了一種靜態Merge方法。 Aspose.PDF 實作: // NuGet: Install-Package Aspose.PDF using Aspose.Pdf; using System; class Program { static void Main() { var document1 = new Document("file1.pdf"); var document2 = new Document("file2.pdf"); foreach (Page page in document2.Pages) { document1.Pages.Add(page); } document1.Save("merged.pdf"); Console.WriteLine("PDFs merged successfully"); } } // NuGet: Install-Package Aspose.PDF using Aspose.Pdf; using System; class Program { static void Main() { var document1 = new Document("file1.pdf"); var document2 = new Document("file2.pdf"); foreach (Page page in document2.Pages) { document1.Pages.Add(page); } document1.Save("merged.pdf"); Console.WriteLine("PDFs merged successfully"); } } $vbLabelText $csharpLabel IronPDF實現: // NuGet: Install-Package IronPdf using IronPdf; using System; using System.Collections.Generic; class Program { static void Main() { var pdf1 = PdfDocument.FromFile("file1.pdf"); var pdf2 = PdfDocument.FromFile("file2.pdf"); var merged = PdfDocument.Merge(pdf1, pdf2); merged.SaveAs("merged.pdf"); Console.WriteLine("PDFs merged successfully"); } } // NuGet: Install-Package IronPdf using IronPdf; using System; using System.Collections.Generic; class Program { static void Main() { var pdf1 = PdfDocument.FromFile("file1.pdf"); var pdf2 = PdfDocument.FromFile("file2.pdf"); var merged = PdfDocument.Merge(pdf1, pdf2); merged.SaveAs("merged.pdf"); Console.WriteLine("PDFs merged successfully"); } } $vbLabelText $csharpLabel 文字擷取 Aspose.PDF 實作: using Aspose.Pdf; using Aspose.Pdf.Text; var document = new Document("document.pdf"); var absorber = new TextAbsorber(); foreach (Page page in document.Pages) { page.Accept(absorber); } string extractedText = absorber.Text; Console.WriteLine(extractedText); using Aspose.Pdf; using Aspose.Pdf.Text; var document = new Document("document.pdf"); var absorber = new TextAbsorber(); foreach (Page page in document.Pages) { page.Accept(absorber); } string extractedText = absorber.Text; Console.WriteLine(extractedText); $vbLabelText $csharpLabel IronPDF實現: using IronPdf; var pdf = PdfDocument.FromFile("document.pdf"); // Extract all text - one line! string allText = pdf.ExtractAllText(); Console.WriteLine(allText); // Or extract from specific page string page1Text = pdf.ExtractTextFromPage(0); using IronPdf; var pdf = PdfDocument.FromFile("document.pdf"); // Extract all text - one line! string allText = pdf.ExtractAllText(); Console.WriteLine(allText); // Or extract from specific page string page1Text = pdf.ExtractTextFromPage(0); $vbLabelText $csharpLabel IronPDF 將文字擷取從多個步驟簡化為單一方法呼叫。 添加浮水印 Aspose.PDF 實作: using Aspose.Pdf; using Aspose.Pdf.Text; var document = new Document("document.pdf"); var textStamp = new TextStamp("CONFIDENTIAL"); textStamp.Background = true; textStamp.XIndent = 100; textStamp.YIndent = 100; textStamp.Rotate = Rotation.on45; textStamp.Opacity = 0.5; textStamp.TextState.Font = FontRepository.FindFont("Arial"); textStamp.TextState.FontSize = 72; textStamp.TextState.ForegroundColor = Color.Red; foreach (Page page in document.Pages) { page.AddStamp(textStamp); } document.Save("watermarked.pdf"); using Aspose.Pdf; using Aspose.Pdf.Text; var document = new Document("document.pdf"); var textStamp = new TextStamp("CONFIDENTIAL"); textStamp.Background = true; textStamp.XIndent = 100; textStamp.YIndent = 100; textStamp.Rotate = Rotation.on45; textStamp.Opacity = 0.5; textStamp.TextState.Font = FontRepository.FindFont("Arial"); textStamp.TextState.FontSize = 72; textStamp.TextState.ForegroundColor = Color.Red; foreach (Page page in document.Pages) { page.AddStamp(textStamp); } document.Save("watermarked.pdf"); $vbLabelText $csharpLabel IronPDF實現: using IronPdf; using IronPdf.Editing; var pdf = PdfDocument.FromFile("document.pdf"); // HTML-based watermark with full styling control string watermarkHtml = @" <div style=' color: red; opacity: 0.5; font-family: Arial; font-size: 72px; font-weight: bold; text-align: center; '>CONFIDENTIAL</div>"; pdf.ApplyWatermark(watermarkHtml, rotation: 45, verticalAlignment: VerticalAlignment.Middle, horizontalAlignment: HorizontalAlignment.Center); pdf.SaveAs("watermarked.pdf"); using IronPdf; using IronPdf.Editing; var pdf = PdfDocument.FromFile("document.pdf"); // HTML-based watermark with full styling control string watermarkHtml = @" <div style=' color: red; opacity: 0.5; font-family: Arial; font-size: 72px; font-weight: bold; text-align: center; '>CONFIDENTIAL</div>"; pdf.ApplyWatermark(watermarkHtml, rotation: 45, verticalAlignment: VerticalAlignment.Middle, horizontalAlignment: HorizontalAlignment.Center); pdf.SaveAs("watermarked.pdf"); $vbLabelText $csharpLabel IronPDF 使用基於 HTML/CSS 的浮水印技術,透過熟悉的 Web 技術提供完整的樣式控制。 密碼保護 Aspose.PDF 實作: using Aspose.Pdf; var document = new Document("document.pdf"); document.Encrypt("userPassword", "ownerPassword", DocumentPrivilege.ForbidAll, CryptoAlgorithm.AESx256); document.Save("protected.pdf"); using Aspose.Pdf; var document = new Document("document.pdf"); document.Encrypt("userPassword", "ownerPassword", DocumentPrivilege.ForbidAll, CryptoAlgorithm.AESx256); document.Save("protected.pdf"); $vbLabelText $csharpLabel IronPDF實現: using IronPdf; var pdf = PdfDocument.FromFile("document.pdf"); // Set passwords pdf.SecuritySettings.UserPassword = "userPassword"; pdf.SecuritySettings.OwnerPassword = "ownerPassword"; // Set permissions pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights; pdf.SecuritySettings.AllowUserCopyPasteContent = false; pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit; pdf.SaveAs("protected.pdf"); using IronPdf; var pdf = PdfDocument.FromFile("document.pdf"); // Set passwords pdf.SecuritySettings.UserPassword = "userPassword"; pdf.SecuritySettings.OwnerPassword = "ownerPassword"; // Set permissions pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights; pdf.SecuritySettings.AllowUserCopyPasteContent = false; pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit; pdf.SaveAs("protected.pdf"); $vbLabelText $csharpLabel IronPDF 透過強型別屬性提供權限的精細控制。 更多選項請參閱加密文件。 頁首和頁尾 IronPDF實現: using IronPdf; var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter { HtmlFragment = @" <div style='text-align:center; font-family:Arial; font-size:12px;'> Company Header </div>", DrawDividerLine = true, MaxHeight = 30 }; renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter { HtmlFragment = @" <div style='text-align:center; font-family:Arial; font-size:10px;'> Page {page} of {total-pages} </div>", DrawDividerLine = true, MaxHeight = 25 }; var pdf = renderer.RenderHtmlAsPdf("<h1>Content here</h1>"); pdf.SaveAs("with_headers.pdf"); using IronPdf; var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter { HtmlFragment = @" <div style='text-align:center; font-family:Arial; font-size:12px;'> Company Header </div>", DrawDividerLine = true, MaxHeight = 30 }; renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter { HtmlFragment = @" <div style='text-align:center; font-family:Arial; font-size:10px;'> Page {page} of {total-pages} </div>", DrawDividerLine = true, MaxHeight = 25 }; var pdf = renderer.RenderHtmlAsPdf("<h1>Content here</h1>"); pdf.SaveAs("with_headers.pdf"); $vbLabelText $csharpLabel IronPDF 支援使用{page}和{total-pages}等佔位符號標記進行動態頁碼編號。 更多選項請參閱頁首和頁尾文件。 關鍵遷移說明 頁面索引更改 Aspose.PDF 使用基於 1 的索引。 IronPDF 使用從 0 開始的索引: // Aspose.PDF - 1-based indexing var firstPage = doc.Pages[1]; // First page var thirdPage = doc.Pages[3]; // Third page // IronPDF - 0-based indexing var firstPage = pdf.Pages[0]; // First page var thirdPage = pdf.Pages[2]; // Third page // Aspose.PDF - 1-based indexing var firstPage = doc.Pages[1]; // First page var thirdPage = doc.Pages[3]; // Third page // IronPDF - 0-based indexing var firstPage = pdf.Pages[0]; // First page var thirdPage = pdf.Pages[2]; // Third page $vbLabelText $csharpLabel 許可證文件到代碼密鑰 將.lic檔案許可替換為基於程式碼的啟動: // Aspose.PDF var license = new Aspose.Pdf.License(); license.SetLicense("Aspose.Pdf.lic"); // IronPDF IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"; // Or from environment variable IronPdf.License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE_KEY"); // Aspose.PDF var license = new Aspose.Pdf.License(); license.SetLicense("Aspose.Pdf.lic"); // IronPDF IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"; // Or from environment variable IronPdf.License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE_KEY"); $vbLabelText $csharpLabel ASP.NET Core 集成 IronPDF 圖案: [ApiController] [Route("[controller]")] public class PdfController : ControllerBase { [HttpGet("generate")] public IActionResult GeneratePdf() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1>"); return File(pdf.BinaryData, "application/pdf", "report.pdf"); } [HttpGet("generate-async")] public async Task<IActionResult> GeneratePdfAsync() { var renderer = new ChromePdfRenderer(); var pdf = await renderer.RenderHtmlAsPdfAsync("<h1>Report</h1>"); return File(pdf.Stream, "application/pdf", "report.pdf"); } } [ApiController] [Route("[controller]")] public class PdfController : ControllerBase { [HttpGet("generate")] public IActionResult GeneratePdf() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1>"); return File(pdf.BinaryData, "application/pdf", "report.pdf"); } [HttpGet("generate-async")] public async Task<IActionResult> GeneratePdfAsync() { var renderer = new ChromePdfRenderer(); var pdf = await renderer.RenderHtmlAsPdfAsync("<h1>Report</h1>"); return File(pdf.Stream, "application/pdf", "report.pdf"); } } $vbLabelText $csharpLabel 依賴注入配置 // Program.cs public void ConfigureServices(IServiceCollection services) { // Set license once IronPdf.License.LicenseKey = Configuration["IronPdf:LicenseKey"]; // Register renderer as scoped service services.AddScoped<ChromePdfRenderer>(); } // Program.cs public void ConfigureServices(IServiceCollection services) { // Set license once IronPdf.License.LicenseKey = Configuration["IronPdf:LicenseKey"]; // Register renderer as scoped service services.AddScoped<ChromePdfRenderer>(); } $vbLabelText $csharpLabel 效能最佳化 // 1. Reuse renderer instance private static readonly ChromePdfRenderer SharedRenderer = new ChromePdfRenderer(); // 2. Disable unnecessary features for speed var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.EnableJavaScript = false; // If not needed renderer.RenderingOptions.WaitFor.RenderDelay(0); // No delay renderer.RenderingOptions.Timeout = 30000; // 30s max // 3. Proper disposal using (var pdf = renderer.RenderHtmlAsPdf(html)) { pdf.SaveAs("output.pdf"); } // 1. Reuse renderer instance private static readonly ChromePdfRenderer SharedRenderer = new ChromePdfRenderer(); // 2. Disable unnecessary features for speed var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.EnableJavaScript = false; // If not needed renderer.RenderingOptions.WaitFor.RenderDelay(0); // No delay renderer.RenderingOptions.Timeout = 30000; // 30s max // 3. Proper disposal using (var pdf = renderer.RenderHtmlAsPdf(html)) { pdf.SaveAs("output.pdf"); } $vbLabelText $csharpLabel 解決常見遷移問題 問題:未找到 HtmlLoadOptions 替換為ChromePdfRenderer : // Remove this var doc = new Document(stream, new HtmlLoadOptions()); // Use this var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(htmlString); // Remove this var doc = new Document(stream, new HtmlLoadOptions()); // Use this var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(htmlString); $vbLabelText $csharpLabel 問題:未找到 TextFragmentAbsorber 使用直接文字擷取: // Remove this var absorber = new TextFragmentAbsorber(); page.Accept(absorber); string text = absorber.Text; // Use this var pdf = PdfDocument.FromFile("doc.pdf"); string text = pdf.ExtractAllText(); // Remove this var absorber = new TextFragmentAbsorber(); page.Accept(absorber); string text = absorber.Text; // Use this var pdf = PdfDocument.FromFile("doc.pdf"); string text = pdf.ExtractAllText(); $vbLabelText $csharpLabel 問題:PdfFileEditor.Concatenate 不可用 使用PdfDocument.Merge() : // Remove this var editor = new PdfFileEditor(); editor.Concatenate(files, output); // Use this var pdfs = files.Select(PdfDocument.FromFile).ToList(); var merged = PdfDocument.Merge(pdfs); merged.SaveAs(output); // Remove this var editor = new PdfFileEditor(); editor.Concatenate(files, output); // Use this var pdfs = files.Select(PdfDocument.FromFile).ToList(); var merged = PdfDocument.Merge(pdfs); merged.SaveAs(output); $vbLabelText $csharpLabel 遷移後檢查清單 程式碼遷移完成後,請驗證以下內容: 刪除 Aspose.PDF 許可證文件(.lic) 驗證 HTML 渲染品質(CSS Grid、Flexbox 現在應該可以正常運作) 使用大型文件和複雜的 CSS 測試極端情況 更新頁面索引引用(從 1 開始到 0 開始) 如果需要,更新 Docker 配置 使用新的許可證金鑰配置更新 CI/CD 管線 為你的團隊記錄新模式 讓您的 PDF 基礎架構面向未來 隨著 .NET 10 即將到來,C# 14 也引入了新的語言特性,選擇一個具有現代渲染功能的 PDF 庫可以確保與不斷發展的網路標準相容。 IronPDF 的 Chromium 引擎渲染的 HTML/CSS 與現代瀏覽器中使用的相同,這意味著您的 PDF 模板在專案擴展到 2025 年和 2026 年時仍能保持最新狀態,而不會受到 Aspose.PDF 的 Flying Saucer 引擎的 CSS 限制。 其他資源 IronPDF 文件 HTML 轉 PDF 教學課程 API 參考 NuGet 套件 -授權選項 從 Aspose.PDF 遷移到 IronPDF 會將您的 PDF 程式碼庫從過時的 HTML 渲染引擎轉換為基於 Chromium 的現代渲染引擎。 取消 MemoryStream 包裝器、簡化文字擷取和提供更強大的 CSS3 支持,可立即提高生產力,同時將長期授權成本從年度訂閱降低到一次性投資。 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 BitMiracle Docotic PDF to IronPDF in C#How to Migrate from Apryse PDF to I...
發表日期 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. 閱讀更多