MIGRATION GUIDES How to Migrate from Scryber.Core 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 上分享 複製連結 電子郵件文章 從 Scryber.Core 遷移到 IronPDF 會將您的 PDF 產生工作流程從自訂 XML/HTML 解析引擎轉變為具有完整 CSS3 和 JavaScript 支援的現代 鉻 驅動渲染器。 本指南提供了一條完整的、循序漸進的遷移路徑,消除了 LGPL 許可問題、專有模板語法和有限的渲染功能。 為什麼要從 Scryber.Core 遷移到 IronPDF 了解 Scryber.Core Scryber.Core 是一個開源函式庫,它使用 C# 將 HTML 範本轉換為 PDF。 這項特性使其成為熟悉網頁開發和HTML的開發人員的理想工具。 與其他需要特定文件編碼技能的 PDF 解決方案不同,Scryber.Core 利用 HTML 的多功能性和 CSS 樣式功能,提供了一種更直觀的 PDF 生成方法。 雖然 Scryber.Core 對於許多開發者來說是一個可行的選擇,主要是因為它在理念上與開源原則相符,並且提供了靈活性,但它並非沒有限制。 遷移的主要原因 LGPL 許可問題: LGPL 許可要求對庫本身的任何修改都必須開源,這可能會限制某些商業應用程式的使用。 2.自訂模板語法:專有綁定語法需要一定的學習成本。 CSS 支援有限:並非完整的基於瀏覽器的渲染器 4.社群規模較小:文檔和社群案例較少 5.不執行 JavaScript:僅靜態渲染 6.複雜配置:大量使用 XML 的配置方法 7.商業支持有限: Scryber.Core 主要依賴社區支持。 Scryber.Core 與 IronPDF 的比較 方面 Scryber.Core IronPDF 執照 LGPL(限制性) 商業的 渲染引擎 風俗 鉻 CSS 支援 有限的 完整的 CSS3 JavaScript 不 完整版 ES2024 模板綁定 專有 XML 標準型(刮鬍刀等) 學習曲線 自訂語法 標準 HTML/CSS 非同步支援 有限的 滿的 文件 基本的 廣泛的 社區支持 更小 大的 商業支持 有限的 專業支援包括 與 Scryber.Core 相比,IronPDF 提供企業級商業支援、豐富的文件和更大的社群。 該程式庫提供了更靈活的授權選項,沒有 LGPL 限制,使其成為商業應用的理想選擇。 對於計畫在 2025 年和 2026 年採用 .NET 10 和 C# 14 的團隊而言,IronPDF 的現代 鉻 引擎可與當代 Web 標準完全相容。 開始之前 先決條件 .NET 環境: .NET Framework 4.6.2+ 或 .NET Core 3.1+ / .NET 5/6/7/8/9+ NuGet 存取權限:能夠安裝 NuGet 套件 IronPDF 許可證:請從ironpdf.com取得您的許可證密鑰。 NuGet 套件變更 # Remove Scryber.Core dotnet remove package Scryber.Core # Install IronPDF dotnet add package IronPdf # Remove Scryber.Core dotnet remove package Scryber.Core # 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: Scryber.Core using Scryber.Components; using Scryber.Components.Pdf; using Scryber.PDF; using Scryber.Styles; using Scryber.Core; using Scryber.Core.Html; using Scryber.Drawing; // After: IronPDF using IronPdf; using IronPdf.Rendering; // Before: Scryber.Core using Scryber.Components; using Scryber.Components.Pdf; using Scryber.PDF; using Scryber.Styles; using Scryber.Core; using Scryber.Core.Html; using Scryber.Drawing; // After: IronPDF using IronPdf; using IronPdf.Rendering; $vbLabelText $csharpLabel 核心 API 映射 Scryber.Core IronPDF 筆記 Document.ParseDocument(html) renderer.RenderHtmlAsPdf(html) HTML渲染 Document.ParseTemplate(path) renderer.RenderHtmlFileAsPdf(path) 文件渲染 doc.SaveAsPDF(path) pdf.SaveAs(path) 儲存到文件 doc.SaveAsPDF(stream) pdf.Stream或pdf.BinaryData 取得流/位元組 doc.Info.Title pdf.MetaData.Title 元數據 doc.Info.Author pdf.MetaData.Author 元數據 PDFPage pdf.Pages[i] 頁面訪問 PDFLayoutDocument RenderingOptions 佈局控制 PDFStyle HTML 中的 CSS 造型 doc.RenderOptions.PaperSize RenderingOptions.PaperSize 紙張尺寸 資料綁定( {{value}} ) Razor/String 插值 範本 程式碼遷移範例 範例 1:基本的 HTML 轉 PDF 轉換 之前(Scryber.Core): // NuGet: Install-Package Scryber.Core using Scryber.Core; using Scryber.Core.Html; using System.IO; class Program { static void Main() { string html = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; using (var doc = Document.ParseDocument(html, ParseSourceType.DynamicContent)) { doc.SaveAsPDF("output.pdf"); } } } // NuGet: Install-Package Scryber.Core using Scryber.Core; using Scryber.Core.Html; using System.IO; class Program { static void Main() { string html = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; using (var doc = Document.ParseDocument(html, ParseSourceType.DynamicContent)) { doc.SaveAsPDF("output.pdf"); } } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; class Program { static void Main() { var renderer = new ChromePdfRenderer(); string html = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); } } // NuGet: Install-Package IronPdf using IronPdf; class Program { static void Main() { var renderer = new ChromePdfRenderer(); string html = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); } } $vbLabelText $csharpLabel 這個例子展示了架構上的根本差異。 Scryber.Core 使用Document.ParseDocument()和ParseSourceType.DynamicContent參數來解析 HTML 內容,需要using區塊才能正確釋放資源。 然後使用SaveAsPDF()儲存文件。 IronPDF 使用ChromePdfRenderer實例和RenderHtmlAsPdf()直接渲染 HTML。 使用SaveAs()儲存 PDF 檔案。 無需手動處理-IronPDF 會自動處理清理工作。 請參閱HTML 轉 PDF 文件以取得完整範例。 範例 2:URL 轉 PDF 之前(Scryber.Core): // NuGet: Install-Package Scryber.Core using Scryber.Core; using Scryber.Core.Html; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { using var client = new HttpClient(); string html = await client.GetStringAsync("https://www.example.com"); using (var doc = Document.ParseDocument(html, ParseSourceType.DynamicContent)) { doc.SaveAsPDF("webpage.pdf"); } } } // NuGet: Install-Package Scryber.Core using Scryber.Core; using Scryber.Core.Html; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { using var client = new HttpClient(); string html = await client.GetStringAsync("https://www.example.com"); using (var doc = Document.ParseDocument(html, ParseSourceType.DynamicContent)) { doc.SaveAsPDF("webpage.pdf"); } } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; 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; class Program { static void Main() { var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderUrlAsPdf("https://www.example.com"); pdf.SaveAs("webpage.pdf"); } } $vbLabelText $csharpLabel Scryber.Core 無法直接將 URL 轉換為 PDF。 您必須使用HttpClient.GetStringAsync()手動取得 HTML 內容,然後使用Document.ParseDocument()解析下載的 HTML。 這種方法無法執行 JavaScript、動態內容和正確解析 CSS,因為自訂解析器不會執行腳本。 IronPDF 的RenderUrlAsPdf()方法只需一次呼叫即可完成整個流程,包括完整的 JavaScript 執行和使用 鉻 引擎進行的 CSS 渲染。了解更多信息,請參閱我們的教程。 範例 3:自訂頁面設定和邊距 之前(Scryber.Core): // NuGet: Install-Package Scryber.Core using Scryber.Core; using Scryber.Core.Html; using Scryber.Drawing; using System.IO; class Program { static void Main() { string html = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>"; using (var doc = Document.ParseDocument(html, ParseSourceType.DynamicContent)) { doc.RenderOptions.Compression = OutputCompressionType.FlateDecode; doc.RenderOptions.PaperSize = PaperSize.A4; doc.SaveAsPDF("custom.pdf"); } } } // NuGet: Install-Package Scryber.Core using Scryber.Core; using Scryber.Core.Html; using Scryber.Drawing; using System.IO; class Program { static void Main() { string html = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>"; using (var doc = Document.ParseDocument(html, ParseSourceType.DynamicContent)) { doc.RenderOptions.Compression = OutputCompressionType.FlateDecode; doc.RenderOptions.PaperSize = PaperSize.A4; doc.SaveAsPDF("custom.pdf"); } } } $vbLabelText $csharpLabel (IronPDF 之後): // NuGet: Install-Package IronPdf using IronPdf; using IronPdf.Rendering; class Program { static void Main() { var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; renderer.RenderingOptions.MarginTop = 40; renderer.RenderingOptions.MarginBottom = 40; string html = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("custom.pdf"); } } // NuGet: Install-Package IronPdf using IronPdf; using IronPdf.Rendering; class Program { static void Main() { var renderer = new ChromePdfRenderer(); renderer.RenderingOptions.PaperSize = PdfPaperSize.A4; renderer.RenderingOptions.MarginTop = 40; renderer.RenderingOptions.MarginBottom = 40; string html = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("custom.pdf"); } } $vbLabelText $csharpLabel Scryber.Core 使用doc.RenderOptions在解析文件後配置輸出設置,例如Compression (設定為OutputCompressionType.FlateDecode )和PaperSize (設定為PaperSize.A4 )。 IronPDF 在渲染之前會使用渲染器上的RenderingOptions 。 屬性包括PaperSize (設定為PdfPaperSize.A4 )、 MarginTop和MarginBottom單位為毫米。 主要區別在於 IronPDF 透過數值屬性提供直接的邊距控制,而 Scryber.Core 使用基於 XML 的樣式。 模板遷移模式 將專有綁定遷移到標準模板 Scryber.Core 使用專有的基於 XML 的綁定語法,必須將其轉換為標準模板: Scryber.Core綁定: <pdf:Para text='{{model.Name}}' /> <pdf:Para text='Total: {{model.Total:C}}' /> <pdf:ForEach on='{{model.Items}}'> <pdf:Para text='{{.Name}}: {{.Price}}' /> </pdf:ForEach> <pdf:Para text='{{model.Name}}' /> <pdf:Para text='Total: {{model.Total:C}}' /> <pdf:ForEach on='{{model.Items}}'> <pdf:Para text='{{.Name}}: {{.Price}}' /> </pdf:ForEach> XML IronPDF 與 C# 字串插值: var items = model.Items.Select(i => $"<li>{i.Name}: {i.Price:C}</li>"); var html = $@" <p>{model.Name}</p> <p>Total: {model.Total:C}</p> <ul> {string.Join("", items)} </ul>"; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(html); var items = model.Items.Select(i => $"<li>{i.Name}: {i.Price:C}</li>"); var html = $@" <p>{model.Name}</p> <p>Total: {model.Total:C}</p> <ul> {string.Join("", items)} </ul>"; var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf(html); $vbLabelText $csharpLabel 主要優勢:IronPDF 使用標準的 C# 和 HTML,因此您可以使用任何範本引擎(Razor、Handlebars 等),而無需學習專有語法。 頁首和頁尾遷移 Scryber.Core(基於 XML 的頁首/頁尾): <?xml version='1.0' encoding='utf-8' ?> <pdf:Document xmlns:pdf='http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Components.xsd'> <Pages> <pdf:Section> <Header> <pdf:Para text='Company Report' /> </Header> <Footer> <pdf:Para text='Page {{pagenum}} of {{pagetotal}}' /> </Footer> <Content> <pdf:H1 text='Content Here' /> </Content> </pdf:Section> </Pages> </pdf:Document> <?xml version='1.0' encoding='utf-8' ?> <pdf:Document xmlns:pdf='http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Components.xsd'> <Pages> <pdf:Section> <Header> <pdf:Para text='Company Report' /> </Header> <Footer> <pdf:Para text='Page {{pagenum}} of {{pagetotal}}' /> </Footer> <Content> <pdf:H1 text='Content Here' /> </Content> </pdf:Section> </Pages> </pdf:Document> XML IronPDF(HTML頁首/頁尾): using IronPdf; var renderer = new ChromePdfRenderer(); // HTML header with full CSS support renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter { HtmlFragment = @" <div style='width: 100%; text-align: center; font-size: 12pt; border-bottom: 1px solid #ccc;'> Company Report </div>", MaxHeight = 30 }; // HTML footer with page numbers renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter { HtmlFragment = @" <div style='width: 100%; text-align: center; font-size: 10pt;'> Page {page} of {total-pages} </div>", MaxHeight = 25 }; var pdf = renderer.RenderHtmlAsPdf("<h1>Content Here</h1>"); pdf.SaveAs("report.pdf"); using IronPdf; var renderer = new ChromePdfRenderer(); // HTML header with full CSS support renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter { HtmlFragment = @" <div style='width: 100%; text-align: center; font-size: 12pt; border-bottom: 1px solid #ccc;'> Company Report </div>", MaxHeight = 30 }; // HTML footer with page numbers renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter { HtmlFragment = @" <div style='width: 100%; text-align: center; font-size: 10pt;'> Page {page} of {total-pages} </div>", MaxHeight = 25 }; var pdf = renderer.RenderHtmlAsPdf("<h1>Content Here</h1>"); pdf.SaveAs("report.pdf"); $vbLabelText $csharpLabel Scryber.Core 需要基於 XML 的頁首/頁尾定義,以及專有佔位符,例如{{pagenum}}和{{pagetotal}} 。 IronPDF 使用完整的 HTML/CSS 來實現頁首和頁腳,並使用{page}和{total-pages}佔位符。 遷移後的新功能 遷移到 IronPDF 後,您將獲得 Scryber.Core 無法提供的功能: PDF合併 var pdf1 = PdfDocument.FromFile("chapter1.pdf"); var pdf2 = PdfDocument.FromFile("chapter2.pdf"); var pdf3 = PdfDocument.FromFile("chapter3.pdf"); var merged = PdfDocument.Merge(pdf1, pdf2, pdf3); merged.SaveAs("complete_book.pdf"); var pdf1 = PdfDocument.FromFile("chapter1.pdf"); var pdf2 = PdfDocument.FromFile("chapter2.pdf"); var pdf3 = PdfDocument.FromFile("chapter3.pdf"); var merged = PdfDocument.Merge(pdf1, pdf2, pdf3); merged.SaveAs("complete_book.pdf"); $vbLabelText $csharpLabel 安全和元數據 var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>"); // Metadata pdf.MetaData.Title = "My Document"; pdf.MetaData.Author = "John Doe"; pdf.MetaData.Subject = "Annual Report"; pdf.MetaData.Keywords = "report, annual, confidential"; // Security pdf.SecuritySettings.OwnerPassword = "owner123"; pdf.SecuritySettings.UserPassword = "user456"; pdf.SecuritySettings.AllowUserCopyPasteContent = false; pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights; pdf.SaveAs("protected.pdf"); var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>"); // Metadata pdf.MetaData.Title = "My Document"; pdf.MetaData.Author = "John Doe"; pdf.MetaData.Subject = "Annual Report"; pdf.MetaData.Keywords = "report, annual, confidential"; // Security pdf.SecuritySettings.OwnerPassword = "owner123"; pdf.SecuritySettings.UserPassword = "user456"; pdf.SecuritySettings.AllowUserCopyPasteContent = false; pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights; pdf.SaveAs("protected.pdf"); $vbLabelText $csharpLabel 功能對比總結 特徵 Scryber.Core IronPDF HTML 轉 PDF 基本的 全鉻 PDF檔案的URL 手動獲取 原生支援 CSS Grid 有限的 全力支持 Flexbox 有限的 全力支持 JavaScript 不 完整版 ES2024 資料綁定 專有 XML 使用Razor/車把 頁首/頁尾 基於 XML HTML/CSS 合併PDF 有限的 內建 拆分PDF 不 是的 水印 基本的 完整 HTML 數位簽名 不 是的 PDF/A 不 是的 密碼保護 基本的 滿的 非同步支援 有限的 滿的 跨平台 是的 是的 遷移清單 遷移前 審核所有 Scryber 範本的 XML/綁定模式 所使用的文件資料綁定模式( {{model.Property}} ) 識別需要進行 CSS 轉換的自訂樣式 從ironpdf.com取得 IronPDF 許可證金鑰 程式碼更新 移除Scryber.Core NuGet 套件 安裝IronPdf NuGet 套件 更新命名空間導入( using Scryber.Core; → using IronPdf; ) 將Document.ParseDocument(html, ParseSourceType.DynamicContent)替換為renderer.RenderHtmlAsPdf(html) 將doc.SaveAsPDF()替換為pdf.SaveAs() 將 XML 模板轉換為 HTML 將專有綁定替換為標準模板(Razor/字串插值) 更新頁面設定: doc.RenderOptions.PaperSize → renderer.RenderingOptions.PaperSize 將頁首/頁尾轉換為 HTML 格式,並新增{page}和{total-pages}佔位符 在應用程式啟動時新增許可證初始化 測試 測試所有文件模板 驗證樣式是否匹配(充分利用 CSS 支援) 使用新模板測試資料綁定 檢查分頁符 測試帶有頁碼佔位符的頁首/頁腳 效能比較 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 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. 閱讀更多 發表日期 2026年2月1日 How to Migrate from PdfPig to IronPDF in C# Master the migration from PdfPig to IronPDF with this complete C# guide. Switch from a reading-only library to a comprehensive PDF solution. Includes code examples for text extraction, HTML conversion, and metadata access. 閱讀更多 How to Migrate from SelectPdf to IronPDF in C#How to Migrate from SAP Crystal Rep...
發表日期 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 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. 閱讀更多
發表日期 2026年2月1日 How to Migrate from PdfPig to IronPDF in C# Master the migration from PdfPig to IronPDF with this complete C# guide. Switch from a reading-only library to a comprehensive PDF solution. Includes code examples for text extraction, HTML conversion, and metadata access. 閱讀更多