PDFSharp에서 IronPDF로의 마이그레이션 방법 (C#)
PDFSharp에서 IronPDF로 마이그레이션하면 PDF 생성 워크플로우가 수동 좌표 기반 드로잉에서 최신 HTML/CSS 템플릿으로 바뀝니다. 이 가이드는 웹 기술을 통해 지루한 GDI+ 스타일 위치 지정을 대체하여 개발 시간을 크게 줄이고 표준 HTML/CSS 기술을 통해 PDF 생성을 유지할 수 있게 만드는 완전한 단계별 마이그레이션 경로를 제공합니다.
PDFSharp에서 IronPDF로 마이그레이션해야 하는 이유
PDFSharp이해하기
PDFSharp는 프로그래밍 접근 방식을 통해 PDF 문서를 생성할 수 있는 저수준의 PDF 생성 라이브러리로 잘 알려져 있습니다. MIT 라이센스 하에 출시된 PDFSharp은 개발자 커뮤니티에게 사용 및 수정의 자유를 제공합니다. PDFSharp는 주로 처음부터 PDF를 그리거나 컴파일하기 위한 도구로 작동하며, 프로젝트의 성격에 따라 유용할 수도 있고 제한적일 수도 있습니다.
PDFSharp는 때때로 HTML-to-PDF 변환기라고 잘못 추정되지만, 그렇지 않습니다. 이 라이브러리는 프로그래밍 방식의 PDF 문서 생성에만 전념합니다. HtmlRenderer.PdfSharp라는 추가 기능이 HTML 렌더링 기능을 제공하도록 되어 있지만, CSS 2.1만 지원하며 flexbox나 grid와 같은 최신 CSS 기능은 지원하지 않습니다.
좌표 계산 문제
PDFSharp의 GDI+ 접근 방식은 다음을 의미합니다:
- 각 구성 요소에 대한 정확한 X,Y 위치를 계산
- 페이지 오버플로에 대한 콘텐츠 높이 수동 추적
- 라인 래핑 및 텍스트 측정을 직접 처리
- 테이블을 셀 별로 그리고 경계 계산
- 수동 페이지 구문을 통한 다중 페이지 문서 관리
PDFSharp의 아키텍처는 좌표를 사용한 위치 지정에 대한 깊은 이해를 요구하며, 복잡한 레이아웃을 만드는 데 어려움을 줄 수 있습니다.
PDFSharpvsIronPDF비교
| 기능 | PDFSharp | IronPDF |
|---|---|---|
| 라이선스 | MIT (무료) | 상업적 |
| HTML to PDF 지원 | 아니요 | 예 (HTML5/CSS3 지원) |
| 최신 CSS 지원 | 아니요 (CSS 2.1만 지원) | 예 (전체 CSS3 지원) |
| 문서 생성 | 좌표 기반 드로잉 | HTML/CSS 템플릿 |
| 레이아웃 시스템 | 수동 X,Y 위치 지정 | CSS 흐름/플렉스박스/그리드 |
| 페이지 구문 | 수동 계산 | 자동 + CSS 제어 |
| 테이블 | 셀 개별 드로잉 | HTML <table> |
| 스타일링 | 코드 기반 글꼴/색상 | CSS 스타일시트 |
| 문서 API | 저수준 (좌표 요구) | 고수준 (간소화된 API) |
| 업데이트 | 드문드문함 | 정규 |
IronPDF는 HTML 문서를 PDF로 전체 충실도 변환해야 하는 시나리오에서 빛을 발합니다. 이 .NET 라이브러리는 HTML5 및 CSS3을 지원하여 최신 웹 표준을 충족시킵니다. 그의 네이티브 HTML-to-PDF 기능 덕분에 개발자는 기존 웹 콘텐츠 또는 현대적인 웹 도구로 설계된 템플릿을 활용할 수 있습니다.
2025년과 2026년까지 .NET 10 및 C# 14 채택을 계획하는 팀에게 IronPDF는 좌표 계산을 제거하고 웹 개발 기술을 활용하는 현대적인 접근 방식을 제공합니다.
시작하기 전에
필수 조건
- .NET 환경: .NET Framework 4.6.2+ 또는 .NET Core 3.1+ / .NET 5/6/7/8/9+
- NuGet 접근 권한: NuGet 패키지를 설치할 수 있는 능력
- IronPDF 라이선스: ironpdf.com에서 라이선스 키를 획득하세요
NuGet 패키지 변경 사항
# 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
라이선스 구성
// 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";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
PDFSharp사용 식별하기
# Find allPDFSharpusages in your codebase
grep -r "PdfSharp\|XGraphics\|XFont\|XBrush\|XPen" --include="*.cs" .
# Find allPDFSharpusages in your codebase
grep -r "PdfSharp\|XGraphics\|XFont\|XBrush\|XPen" --include="*.cs" .
완전한 API 참조
네임스페이스 변경
// 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;
Imports IronPdf
Imports IronPdf.Editing
핵심 API 매핑
| PDFSharp API | IronPDF API |
|---|---|
new PdfDocument() |
ChromePdfRenderer.RenderHtmlAsPdf() |
document.AddPage() |
자동 |
XGraphics.FromPdfPage() |
필요 없음 |
XGraphics.DrawString() |
HTML <p>, <h1>, 등 |
XGraphics.DrawImage() |
HTML <img> 태그 |
XFont |
CSS font-family, font-size |
XBrush, XPen |
CSS 색상/경계 |
document.Save() |
pdf.SaveAs() |
PdfReader.Open() |
PdfDocument.FromFile() |
코드 마이그레이션 예제
예제 1: HTML에서 PDF로 변환
이전 (PDFSharp):
// NuGet: Install-Package PdfSharp
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
//PDFSharpdoes not have built-inHTML to PDFconversion
// 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);
//수동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()
{
//PDFSharpdoes not have built-inHTML to PDFconversion
// 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);
//수동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");
}
}
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports System
Module Program
Sub Main()
' PDFSharp does not have built-in HTML to PDF conversion
' You need to manually parse HTML and render content
Dim document As New PdfDocument()
Dim page As PdfPage = document.AddPage()
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
Dim font As New XFont("Arial", 12)
' 수동 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")
End Sub
End Module
이후 (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
//IronPDFhas nativeHTML to PDFrendering
var renderer = new ChromePdfRenderer();
string html = "<h1>Hello from IronPDF</h1><p>EasyHTML to PDFconversion</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
//IronPDFhas nativeHTML to PDFrendering
var renderer = new ChromePdfRenderer();
string html = "<h1>Hello from IronPDF</h1><p>EasyHTML to PDFconversion</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
' IronPDF has native HTML to PDF rendering
Dim renderer As New ChromePdfRenderer()
Dim html As String = "<h1>Hello from IronPDF</h1><p>Easy HTML to PDF conversion</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
End Sub
End Class
이 예시는 두 라이브러리 간의 가장 큰 차이점을 강조합니다. PDFSharp는 '내장된 HTML에서 PDF 변환 기능이 없다'고 명시합니다—직접 PdfDocument를 생성하고, PdfPage를 추가하고, XGraphics 객체를 얻고, XFont를 생성하고, DrawString()를 XRect 좌표와 함께 사용해야 합니다.
IronPDF는 ChromePdfRenderer을 통해 네이티브 HTML에서 PDF 렌더링을 제공합니다. RenderHtmlAsPdf() 메서드는 HTML 문자열을 받아 내부적으로 Chromium 엔진을 사용하여 변환합니다. IronPDF는 HTML5 및 CSS3에 정의된 모든 스타일을 보존하면서 HTML 파일을 PDF로 쉽게 변환하여 좌표 계산의 필요성을 없앱니다. HTML에서 PDF로의 문서에서 포괄적인 예제를 참조하세요.
예제 2: 기존 PDF에 텍스트/워터마크 추가하기
이전 (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");
}
}
Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.IO
Imports PdfSharp.Drawing
Imports System
Module Program
Sub Main()
' Open existing PDF
Dim document As PdfDocument = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify)
Dim page As PdfPage = document.Pages(0)
' Get graphics object
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
Dim font As 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")
End Sub
End Module
이후 (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");
}
}
Imports IronPdf
Imports IronPdf.Editing
Imports System
Module Program
Sub Main()
' Open existing PDF
Dim pdf = PdfDocument.FromFile("existing.pdf")
' Add text stamp/watermark
Dim textStamper = New TextStamper() With {
.Text = "Watermark Text",
.FontSize = 20,
.Color = IronSoftware.Drawing.Color.Red,
.VerticalAlignment = VerticalAlignment.Middle,
.HorizontalAlignment = HorizontalAlignment.Center
}
pdf.ApplyStamp(textStamper)
pdf.SaveAs("modified.pdf")
End Sub
End Module
PDFSharp는 PdfReader.Open()을 사용하여 PDF를 열고 PdfDocumentOpenMode.Modify을 지정하고, 페이지에 접근하며, XGraphics 객체를 생성하고, 스타일이 있는 XFont을 생성하며, DrawString()을 XPoint와 함께 정확한 X,Y 좌표 (200, 400)를 지정하여 사용해야 합니다.
IronPDF는 PdfDocument.FromFile(), 선언적 속성 (Text, FontSize, Color, VerticalAlignment, HorizontalAlignment)이 있는 TextStamper 객체 및 ApplyStamp()로 이를 간소화합니다. IronPDF에서는 정렬만 지정하면 좌표 계산이 필요 없고, IronPDF가 위치를 처리합니다. IronPdf.Editing 네임스페이스는 스탬핑 기능을 위해 필요하다는 점을 유의하세요.
예제 3: 이미지로 PDF 생성하기
이전 (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");
}
}
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports System
Module Program
Sub Main()
' Create new PDF document
Dim document As New PdfDocument()
Dim page As PdfPage = document.AddPage()
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
' Load and draw image
Dim image As XImage = XImage.FromFile("image.jpg")
' Calculate size to fit page
Dim width As Double = 200
Dim height As Double = 200
gfx.DrawImage(image, 50, 50, width, height)
' Add text
Dim font As New XFont("Arial", 16)
gfx.DrawString("Image in PDF", font, XBrushes.Black, New XPoint(50, 270))
document.Save("output.pdf")
End Sub
End Module
이후 (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);
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
' Create PDF from HTML with image
Dim renderer = New ChromePdfRenderer()
Dim html As String = "
<h1>Image in PDF</h1>
<img src='image.jpg' style='width:200px; height:200px;' />
<p>Easy image embedding with HTML</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
' Alternative: Add image to existing PDF
Dim existingPdf = New ChromePdfRenderer().RenderHtmlAsPdf("<h1>Document</h1>")
Dim imageStamper = New IronPdf.Editing.ImageStamper(New Uri("image.jpg")) With {
.VerticalAlignment = IronPdf.Editing.VerticalAlignment.Top
}
existingPdf.ApplyStamp(imageStamper)
End Sub
End Class
PDFSharp는 새로운 PdfDocument을 생성하고, PdfPage을 추가하며, XGraphics를 얻고, 파일에서 XImage를 로딩하고, 너비와 높이를 계산하며, 정확한 좌표 (50, 50, 200, 200)로 DrawImage()를 사용한 후, DrawString()로 텍스트를 별도로 추가해야 합니다.
IronPDF는 표준 HTML 및 CSS 스타일링과 함께 <img> 태그를 사용합니다 (style='width:200px; height:200px;')을 사용합니다. 좌표 계산이 필요 없으며, CSS가 레이아웃을 처리합니다. IronPDF는 또한 선언적 정렬 속성과 함께 기존 PDF에 이미지를 추가하기 위한 ImageStamper를 제공합니다. 더 많은 정보를 보려면 튜토리얼을 참조하세요.
중요한 마이그레이션 노트
패러다임 전환: 좌표에서 HTML/CSS로
가장 큰 변화는 좌표 기반 그림에서 HTML/CSS로 이동하는 것입니다:
// PDFSharp:수동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:수동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);
Imports PdfSharp.Drawing
Imports IronPdf
' PDFSharp: 수동 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
Dim html As String = "
<div style='padding: 50px;'>
<h1>Invoice</h1>
<p>Customer: John</p>
</div>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
폰트 마이그레이션
// 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>";
Dim titleFont As New XFont("Arial", 24, XFontStyle.Bold)
Dim bodyFont As New XFont("Times New Roman", 12)
Dim html As String = "
<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: 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");
Imports PdfSharp
Imports IronPDF
' PDFSharp: PdfReader.Open()
Dim document As PdfDocument = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify)
' IronPDF: PdfDocument.FromFile()
Dim pdf = PdfDocument.FromFile("existing.pdf")
저장 방법 변경
// 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");
페이지 접근 방식 변경
// PDFSharp: document.Pages[0]
PdfPage page = document.Pages[0];
// IronPDF:자동page handling or pdf.Pages[0]
// Pages are created automatically from HTML content
// PDFSharp: document.Pages[0]
PdfPage page = document.Pages[0];
// IronPDF:자동page handling or pdf.Pages[0]
// Pages are created automatically from HTML content
' PDFSharp: document.Pages(0)
Dim page As PdfPage = document.Pages(0)
' IronPDF: 자동 page handling or pdf.Pages(0)
' Pages are created automatically from HTML content
이동 후 새로운 기능
IronPDF로 마이그레이션 한 후에는 PDFSharp이 제공할 수 없는 기능을 얻을 수 있습니다:
네이티브 HTML에서 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>");
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Modern Web Content</h1>")
URL에서 PDF로
var pdf = renderer.RenderUrlAsPdf("https://example.com");
var pdf = renderer.RenderUrlAsPdf("https://example.com");
Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
PDF 병합
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);
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
HTML을 사용한 워터마크
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>")
기능 비교 요약
| 기능 | PDFSharp | IronPDF |
|---|---|---|
| 좌표 기반 그리기 | ✓ | ✗(HTML 사용) |
| HTML to PDF | ✗ | ✓ |
| CSS3 지원 | ✗ | ✓ |
| 플렉스박스/그리드 레이아웃 | ✗ | ✓ |
| 텍스트 스탬핑 | 수동 XGraphics | 텍스트스탬퍼 |
| 이미지 스탬핑 | 수동 XImage | 이미지스탬퍼 |
| PDF 병합 | 수동 | ✓ |
| URL을 PDF로 변환 | ✗ | ✓ |
| 모던 웹 렌더링 | ✗ | Chromium 엔진 |
| 자동 페이지 구분 | ✗ | ✓ |
마이그레이션 체크리스트
사전 마이그레이션
- 코드베이스에서 모든PDFSharp사용 사례 목록 작성
- 생성되는 문서 유형 식별 (보고서, 송장, 인증서)
- 사용자 정의 그래픽 또는 그리기 작업 기록 -IronPDF라이선스 키 저장 계획 (환경 변수 권장) -IronPDF체험판 라이선스로 먼저 테스트
패키지 변경 사항
PdfSharpNuGet 패키지를 제거하십시오- 사용 중인 경우
PdfSharp-wpfNuGet 패키지를 제거하십시오 - 사용 중인 경우
PdfSharp.ChartingNuGet 패키지를 제거하십시오 - NuGet 패키지를 설치하십시오:
IronPdf:dotnet add package IronPdf
코드 변경 사항
- 네임스페이스 임포트를 업데이트하십시오 (
using PdfSharp.Pdf;→using IronPdf;) - 스탬핑 기능을 위해
using IronPdf.Editing;을 추가하십시오 - 좌표 기반 레이아웃을 HTML/CSS로 변환
XFont을 CSS 폰트 속성으로 교체하십시오XPen을 CSS 색상/테두리로 교체하십시오XGraphics.DrawString()을 HTML 텍스트 요소로 교체하십시오XGraphics.DrawImage()을 HTML<img>태그로 교체하십시오PdfReader.Open()을PdfDocument.FromFile()로 교체하십시오document.Save()을pdf.SaveAs()로 교체하십시오- 테이블 그리기 코드를 HTML 테이블로 변환
마이그레이션 이후
- 생성된 PDF의 시각적 비교
- 다중 페이지 문서 테스트
- 글꼴 렌더링 확인
- 필요한 경우 새로운 기능 추가 (HTML to PDF, 병합, 워터마크)

