MIGRATION GUIDES How to Migrate from PDFSharp to IronPDF in C# 커티스 차우 게시됨:2월 1, 2026 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 Migrating from PDFSharp to IronPDF transforms your PDF generation workflow from manual coordinate-based drawing to modern HTML/CSS templating. This guide provides a complete, step-by-step migration path that replaces tedious GDI+ style positioning with web technologies, dramatically reducing development time and making PDF generation maintainable through standard HTML/CSS skills. Why Migrate from PDFSharp to IronPDF Understanding PDFSharp PDFSharp is renowned as a low-level PDF creation library, allowing developers to generate PDF documents through a programmatic approach. Released under the MIT license, PDFSharp grants the developer community freedom in usage and modification. PDFSharp primarily functions as a tool for drawing and compiling PDFs from scratch, which can both be beneficial and restrictive depending on the project's nature. PDFSharp is sometimes mistakenly assumed to be an HTML-to-PDF converter, which it is not. Its purpose is dedicated to programmatic PDF document creation only. While there is an add-on, HtmlRenderer.PdfSharp, intended to provide HTML rendering capabilities, it only supports CSS 2.1, with no support for modern CSS features like flexbox and grid. The Coordinate Calculation Problem PDFSharp's GDI+ approach means you must: Calculate exact X,Y positions for every element Manually track content height for page overflow Handle line wrapping and text measurement yourself Draw tables cell by cell with border calculations Manage multi-page documents with manual page breaks PDFSharp's architecture requires a deep understanding of positioning using coordinates, often posing challenges in creating complex layouts. PDFSharp vs IronPDF Comparison Feature PDFSharp IronPDF License MIT (Free) Commercial HTML to PDF Support No Yes (HTML5/CSS3 Support) Modern CSS Support No (CSS 2.1 Only) Yes (Full CSS3) Document Creation Coordinate-based drawing HTML/CSS templates Layout System Manual X,Y positioning CSS Flow/Flexbox/Grid Page Breaks Manual calculation Automatic + CSS control Tables Draw cells individually HTML <table> Styling Code-based fonts/colors CSS stylesheets Document API Low-Level (Requires Coordinates) High-Level (Simplified API) Updates Infrequent Regular IronPDF shines in scenarios where HTML documents need conversion to PDFs with full fidelity. This .NET library supports HTML5 and CSS3, ensuring modern web standards are met. Its native HTML-to-PDF capabilities mean developers can take advantage of existing web content or templates designed with contemporary web tools. For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides a modern approach that eliminates coordinate calculations while leveraging web development skills. Before You Start Prerequisites .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+ NuGet Access: Ability to install NuGet packages IronPDF License: Obtain your license key from ironpdf.com NuGet Package Changes # Remove PDFSharp dotnet remove package PdfSharp dotnet remove package PdfSharp-wpf dotnet remove package PdfSharp.Charting # Add IronPDF dotnet add package IronPdf # Remove PDFSharp dotnet remove package PdfSharp dotnet remove package PdfSharp-wpf dotnet remove package PdfSharp.Charting # Add IronPDF dotnet add package IronPdf SHELL License Configuration // Add at application startup (Program.cs or Startup.cs) IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"; // Add at application startup (Program.cs or Startup.cs) IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"; $vbLabelText $csharpLabel Identify PDFSharp Usage # Find all PDFSharp usages in your codebase grep -r "PdfSharp\|XGraphics\|XFont\|XBrush\|XPen" --include="*.cs" . # Find all PDFSharp usages in your codebase grep -r "PdfSharp\|XGraphics\|XFont\|XBrush\|XPen" --include="*.cs" . SHELL Complete API Reference Namespace Changes // Before: PDFSharp using PdfSharp.Pdf; using PdfSharp.Drawing; using PdfSharp.Pdf.IO; // After: IronPDF using IronPdf; using IronPdf.Editing; // Before: PDFSharp using PdfSharp.Pdf; using PdfSharp.Drawing; using PdfSharp.Pdf.IO; // After: IronPDF using IronPdf; using IronPdf.Editing; $vbLabelText $csharpLabel Core API Mappings PDFSharp API IronPDF API new PdfDocument() ChromePdfRenderer.RenderHtmlAsPdf() document.AddPage() Automatic XGraphics.FromPdfPage() Not needed XGraphics.DrawString() HTML <p>, <h1>, etc. XGraphics.DrawImage() HTML <img> tag XFont CSS font-family, font-size XBrush, XPen CSS colors/borders document.Save() pdf.SaveAs() PdfReader.Open() PdfDocument.FromFile() Code Migration Examples Example 1: HTML to PDF Conversion Before (PDFSharp): // NuGet: Install-Package PdfSharp using PdfSharp.Pdf; using PdfSharp.Drawing; using System; class Program { static void Main() { // PDFSharp does not have built-in HTML to PDF conversion // You need to manually parse HTML and render content PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Arial", 12); // Manual text rendering (no HTML support) gfx.DrawString("Hello from PDFSharp", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.TopLeft); document.Save("output.pdf"); } } // NuGet: Install-Package PdfSharp using PdfSharp.Pdf; using PdfSharp.Drawing; using System; class Program { static void Main() { // PDFSharp does not have built-in HTML to PDF conversion // You need to manually parse HTML and render content PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Arial", 12); // Manual text rendering (no HTML support) gfx.DrawString("Hello from PDFSharp", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.TopLeft); document.Save("output.pdf"); } } $vbLabelText $csharpLabel After (IronPDF): // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { // IronPDF has native HTML to PDF rendering var renderer = new ChromePdfRenderer(); string html = "<h1>Hello from IronPDF</h1><p>Easy HTML to PDF conversion</p>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); } } // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { // IronPDF has native HTML to PDF rendering var renderer = new ChromePdfRenderer(); string html = "<h1>Hello from IronPDF</h1><p>Easy HTML to PDF conversion</p>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); } } $vbLabelText $csharpLabel This example highlights the most significant difference between the two libraries. PDFSharp explicitly states it "does not have built-in HTML to PDF conversion"—you must manually create a PdfDocument, add a PdfPage, get an XGraphics object, create an XFont, and use DrawString() with XRect coordinates. IronPDF provides native HTML to PDF rendering through ChromePdfRenderer. The RenderHtmlAsPdf() method accepts HTML strings and converts them using a Chromium engine internally. IronPDF easily converts HTML files to PDF, preserving all styles defined in HTML5 and CSS3, eliminating the need for coordinate calculations. See the HTML to PDF documentation for comprehensive examples. Example 2: Adding Text/Watermark to Existing PDF Before (PDFSharp): // NuGet: Install-Package PdfSharp using PdfSharp.Pdf; using PdfSharp.Pdf.IO; using PdfSharp.Drawing; using System; class Program { static void Main() { // Open existing PDF PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify); PdfPage page = document.Pages[0]; // Get graphics object XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Arial", 20, XFontStyle.Bold); // Draw text at specific position gfx.DrawString("Watermark Text", font, XBrushes.Red, new XPoint(200, 400)); document.Save("modified.pdf"); } } // NuGet: Install-Package PdfSharp using PdfSharp.Pdf; using PdfSharp.Pdf.IO; using PdfSharp.Drawing; using System; class Program { static void Main() { // Open existing PDF PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify); PdfPage page = document.Pages[0]; // Get graphics object XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Arial", 20, XFontStyle.Bold); // Draw text at specific position gfx.DrawString("Watermark Text", font, XBrushes.Red, new XPoint(200, 400)); document.Save("modified.pdf"); } } $vbLabelText $csharpLabel After (IronPDF): // NuGet: Install-Package IronPdf using IronPdf; using IronPdf.Editing; using System; class Program { static void Main() { // Open existing PDF var pdf = PdfDocument.FromFile("existing.pdf"); // Add text stamp/watermark var textStamper = new TextStamper() { Text = "Watermark Text", FontSize = 20, Color = IronSoftware.Drawing.Color.Red, VerticalAlignment = VerticalAlignment.Middle, HorizontalAlignment = HorizontalAlignment.Center }; pdf.ApplyStamp(textStamper); pdf.SaveAs("modified.pdf"); } } // NuGet: Install-Package IronPdf using IronPdf; using IronPdf.Editing; using System; class Program { static void Main() { // Open existing PDF var pdf = PdfDocument.FromFile("existing.pdf"); // Add text stamp/watermark var textStamper = new TextStamper() { Text = "Watermark Text", FontSize = 20, Color = IronSoftware.Drawing.Color.Red, VerticalAlignment = VerticalAlignment.Middle, HorizontalAlignment = HorizontalAlignment.Center }; pdf.ApplyStamp(textStamper); pdf.SaveAs("modified.pdf"); } } $vbLabelText $csharpLabel PDFSharp requires opening the PDF with PdfReader.Open() specifying PdfDocumentOpenMode.Modify, accessing a page, creating an XGraphics object, creating an XFont with style, and using DrawString() with an XPoint specifying exact X,Y coordinates (200, 400). IronPDF simplifies this with PdfDocument.FromFile(), a TextStamper object with declarative properties (Text, FontSize, Color, VerticalAlignment, HorizontalAlignment), and ApplyStamp(). No coordinate calculations needed—just specify alignment and IronPDF handles positioning. Note the IronPdf.Editing namespace is required for stamping functionality. Example 3: Creating PDF with Images Before (PDFSharp): // NuGet: Install-Package PdfSharp using PdfSharp.Pdf; using PdfSharp.Drawing; using System; class Program { static void Main() { // Create new PDF document PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); // Load and draw image XImage image = XImage.FromFile("image.jpg"); // Calculate size to fit page double width = 200; double height = 200; gfx.DrawImage(image, 50, 50, width, height); // Add text XFont font = new XFont("Arial", 16); gfx.DrawString("Image in PDF", font, XBrushes.Black, new XPoint(50, 270)); document.Save("output.pdf"); } } // NuGet: Install-Package PdfSharp using PdfSharp.Pdf; using PdfSharp.Drawing; using System; class Program { static void Main() { // Create new PDF document PdfDocument document = new PdfDocument(); PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); // Load and draw image XImage image = XImage.FromFile("image.jpg"); // Calculate size to fit page double width = 200; double height = 200; gfx.DrawImage(image, 50, 50, width, height); // Add text XFont font = new XFont("Arial", 16); gfx.DrawString("Image in PDF", font, XBrushes.Black, new XPoint(50, 270)); document.Save("output.pdf"); } } $vbLabelText $csharpLabel After (IronPDF): // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { // Create PDF from HTML with image var renderer = new ChromePdfRenderer(); string html = @" <h1>Image in PDF</h1> <img src='image.jpg' style='width:200px; height:200px;' /> <p>Easy image embedding with HTML</p>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); // Alternative: Add image to existing PDF var existingPdf = new ChromePdfRenderer().RenderHtmlAsPdf("<h1>Document</h1>"); var imageStamper = new IronPdf.Editing.ImageStamper(new Uri("image.jpg")) { VerticalAlignment = IronPdf.Editing.VerticalAlignment.Top }; existingPdf.ApplyStamp(imageStamper); } } // NuGet: Install-Package IronPdf using IronPdf; using System; class Program { static void Main() { // Create PDF from HTML with image var renderer = new ChromePdfRenderer(); string html = @" <h1>Image in PDF</h1> <img src='image.jpg' style='width:200px; height:200px;' /> <p>Easy image embedding with HTML</p>"; var pdf = renderer.RenderHtmlAsPdf(html); pdf.SaveAs("output.pdf"); // Alternative: Add image to existing PDF var existingPdf = new ChromePdfRenderer().RenderHtmlAsPdf("<h1>Document</h1>"); var imageStamper = new IronPdf.Editing.ImageStamper(new Uri("image.jpg")) { VerticalAlignment = IronPdf.Editing.VerticalAlignment.Top }; existingPdf.ApplyStamp(imageStamper); } } $vbLabelText $csharpLabel PDFSharp requires creating a new PdfDocument, adding a PdfPage, getting XGraphics, loading an XImage from file, calculating width and height, using DrawImage() with exact coordinates (50, 50, 200, 200), then separately adding text with DrawString(). IronPDF uses standard HTML with an <img> tag and CSS styling (style='width:200px; height:200px;'). No coordinate calculations needed—CSS handles layout. IronPDF also provides ImageStamper for adding images to existing PDFs with declarative alignment properties. Learn more in our tutorials. Critical Migration Notes Paradigm Shift: Coordinates to HTML/CSS The most significant change is moving from coordinate-based drawing to HTML/CSS: // PDFSharp: Manual positioning nightmare gfx.DrawString("Invoice", titleFont, XBrushes.Black, new XPoint(50, 50)); gfx.DrawString("Customer: John", bodyFont, XBrushes.Black, new XPoint(50, 80)); // IronPDF: Let CSS handle layout var html = @" <div style='padding: 50px;'> <h1>Invoice</h1> <p>Customer: John</p> </div>"; var pdf = renderer.RenderHtmlAsPdf(html); // PDFSharp: Manual positioning nightmare gfx.DrawString("Invoice", titleFont, XBrushes.Black, new XPoint(50, 50)); gfx.DrawString("Customer: John", bodyFont, XBrushes.Black, new XPoint(50, 80)); // IronPDF: Let CSS handle layout var html = @" <div style='padding: 50px;'> <h1>Invoice</h1> <p>Customer: John</p> </div>"; var pdf = renderer.RenderHtmlAsPdf(html); $vbLabelText $csharpLabel Font Migration // PDFSharp: XFont objects var titleFont = new XFont("Arial", 24, XFontStyle.Bold); var bodyFont = new XFont("Times New Roman", 12); // IronPDF: CSS font properties var html = @" <style> h1 { font-family: Arial, sans-serif; font-size: 24px; font-weight: bold; } p { font-family: 'Times New Roman', serif; font-size: 12px; } </style>"; // PDFSharp: XFont objects var titleFont = new XFont("Arial", 24, XFontStyle.Bold); var bodyFont = new XFont("Times New Roman", 12); // IronPDF: CSS font properties var html = @" <style> h1 { font-family: Arial, sans-serif; font-size: 24px; font-weight: bold; } p { font-family: 'Times New Roman', serif; font-size: 12px; } </style>"; $vbLabelText $csharpLabel Document Loading Change // PDFSharp: PdfReader.Open() PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify); // IronPDF: PdfDocument.FromFile() var pdf = PdfDocument.FromFile("existing.pdf"); // PDFSharp: PdfReader.Open() PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify); // IronPDF: PdfDocument.FromFile() var pdf = PdfDocument.FromFile("existing.pdf"); $vbLabelText $csharpLabel Save Method Change // PDFSharp: document.Save() document.Save("output.pdf"); // IronPDF: pdf.SaveAs() pdf.SaveAs("output.pdf"); // PDFSharp: document.Save() document.Save("output.pdf"); // IronPDF: pdf.SaveAs() pdf.SaveAs("output.pdf"); $vbLabelText $csharpLabel Page Access Change // PDFSharp: document.Pages[0] PdfPage page = document.Pages[0]; // IronPDF: Automatic page handling or pdf.Pages[0] // Pages are created automatically from HTML content // PDFSharp: document.Pages[0] PdfPage page = document.Pages[0]; // IronPDF: Automatic page handling or pdf.Pages[0] // Pages are created automatically from HTML content $vbLabelText $csharpLabel New Capabilities After Migration After migrating to IronPDF, you gain capabilities that PDFSharp cannot provide: Native HTML to PDF var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Modern Web Content</h1>"); var renderer = new ChromePdfRenderer(); var pdf = renderer.RenderHtmlAsPdf("<h1>Modern Web Content</h1>"); $vbLabelText $csharpLabel URL to PDF var pdf = renderer.RenderUrlAsPdf("https://example.com"); var pdf = renderer.RenderUrlAsPdf("https://example.com"); $vbLabelText $csharpLabel PDF Merging var pdf1 = PdfDocument.FromFile("document1.pdf"); var pdf2 = PdfDocument.FromFile("document2.pdf"); var merged = PdfDocument.Merge(pdf1, pdf2); var pdf1 = PdfDocument.FromFile("document1.pdf"); var pdf2 = PdfDocument.FromFile("document2.pdf"); var merged = PdfDocument.Merge(pdf1, pdf2); $vbLabelText $csharpLabel Watermarks with HTML pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>"); pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>"); $vbLabelText $csharpLabel Feature Comparison Summary Feature PDFSharp IronPDF Coordinate-based Drawing ✓ ✗ (use HTML) HTML to PDF ✗ ✓ CSS3 Support ✗ ✓ Flexbox/Grid Layout ✗ ✓ Text Stamping Manual XGraphics TextStamper Image Stamping Manual XImage ImageStamper Merge PDFs Manual ✓ URL to PDF ✗ ✓ Modern Web Rendering ✗ Chromium Engine Automatic Page Breaks ✗ ✓ Migration Checklist Pre-Migration Inventory all PDFSharp usage in codebase Identify document types being generated (reports, invoices, certificates) Note any custom graphics or drawing operations Plan IronPDF license key storage (environment variables recommended) Test with IronPDF trial license first Package Changes Remove PdfSharp NuGet package Remove PdfSharp-wpf NuGet package if used Remove PdfSharp.Charting NuGet package if used Install IronPdf NuGet package: dotnet add package IronPdf Code Changes Update namespace imports (using PdfSharp.Pdf; → using IronPdf;) Add using IronPdf.Editing; for stamping functionality Convert coordinate-based layouts to HTML/CSS Replace XFont with CSS font properties Replace XBrush/XPen with CSS colors/borders Replace XGraphics.DrawString() with HTML text elements Replace XGraphics.DrawImage() with HTML <img> tags Replace PdfReader.Open() with PdfDocument.FromFile() Replace document.Save() with pdf.SaveAs() Convert table drawing code to HTML tables Post-Migration Visual comparison of generated PDFs Test multi-page documents Verify font rendering Add new capabilities (HTML to PDF, merging, watermarks) as needed 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다. 커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다. 관련 기사 게시됨 2월 1, 2026 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. 더 읽어보기 게시됨 2월 1, 2026 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. 더 읽어보기 게시됨 2월 1, 2026 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 PDFView4NET to IronPDF in C#How to Migrate from PDFreactor to I...
게시됨 2월 1, 2026 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. 더 읽어보기
게시됨 2월 1, 2026 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. 더 읽어보기
게시됨 2월 1, 2026 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. 더 읽어보기