PdfPig에서 IronPDF로의 마이그레이션 방법 (C#)
PdfPig에서 IronPDF로 마이그레이션하면 읽기 전용 라이브러리에서 생성, 조작, 텍스트 추출 및 보안 기능을 처리할 수 있는 포괄적인 PDF 솔루션으로 PDF 기능이 확장됩니다. 이 가이드는 기존의 추출 워크플로를 유지하면서 PdfPig가 제공할 수 없는 PDF 생성, HTML 변환, 문서 조작 및 보안 기능을 추가하는 완전하고 단계적인 마이그레이션 경로를 제공합니다.
왜 PdfPig에서 IronPDF로 마이그레이션해야 하는가
PdfPig이해하기
PdfPig는 C#을 위해 특별히 설계된 오픈 소스 PDF 읽기 및 추출 라이브러리입니다. 평판이 좋은 Apache PDFBox 프로젝트의 일부로, 이 라이브러리는 개발자가 PDF의 콘텐츠에 놀라운 정밀도로 액세스할 수 있도록 합니다. PdfPig은 추출 기능에서 뛰어나지만, 시장에 나와 있는 더 포괄적인 라이브러리에 비해 그 범위는 크게 제한됩니다.
PdfPig는 개발자에게 PDF 파일에서 텍스트, 이미지, 양식 데이터 및 메타데이터를 추출하기 위한 신뢰할 수 있는 도구를 제공합니다. 이는 주로 문서 분석 및 데이터 마이닝에 중점을 둔 애플리케이션에 적합한 선택입니다. 그러나 PdfPig의 기능은 근본적으로 기존 문서를 파싱하는 데 국한되어 있습니다.
읽기 전용 제한
PdfPig는 PDF 읽기에만 중점을 둡니다. 귀하의 애플리케이션이 추출을 넘어서서 성장해야 할 때, PdfPig는 도움이 되지 않습니다:
-
PDF 생성 없음: HTML, URL 또는 프로그래밍 방식으로 PDF를 생성할 수 없습니다.
-
HTML-에서-PDF 없음: PdfPig는 PDF 생성 라이브러리가 아니라 PDF 읽기/파싱 라이브러리입니다. HTML을 PDF로 변환하려면 다른 라이브러리를 사용해야 합니다.
-
문서 조작 없음: PDF를 병합, 분할, 또는 수정할 수 없습니다.
-
보안 기능 없음: 비밀번호, 암호화 또는 디지털 서명을 추가할 수 없습니다.
-
워터마크/도장 없음: 기존 문서에 시각적 오버레이를 추가할 수 없습니다.
- 양식 작성 없음: 프로그래밍적으로 PDF 양식을 작성할 수 없습니다.
PdfPig대IronPDF비교
| 기능 | PdfPig | IronPDF |
|---|---|---|
| 라이선스 | 오픈 소스 (Apache 2.0) | 상업적 |
| PDF 읽기/추출 | 우수함 | 우수함 |
| PDF 생성 | 제한적 | 포괄적 |
| HTML to PDF | 지원되지 않음 | 지원됨 |
| 텍스트 추출 | 우수함 | 우수함 |
| PDF 조작 | 지원되지 않음 | 병합, 분할, 회전 |
| 워터마크 | 지원되지 않음 | 지원됨 |
| 보안/암호화 | 지원되지 않음 | 지원됨 |
| 지원 및 문서 | 커뮤니티 지원 | 전용 지원 |
| 페이지 색인 | 1 기반 | 0 기반 |
IronPDF는 PDF를 생성, 읽기, 편집 및 서명하는 데 필요한 완전한 기능 세트를 지원합니다. 이 다재다능함 덕분에 개발자는 PDF 파일을 처음부터 끝까지 관리할 수 있습니다. .NET 10 및 C# 14 채택을 2025년과 2026년까지 계획하는 팀에게 IronPDF는 PdfPig의 읽기 기능을 넘어 확장되는 완전한 PDF 수명 주기 솔루션을 제공합니다.
시작하기 전에
필수 조건
- .NET 환경: .NET Framework 4.6.2+ 또는 .NET Core 3.1+ / .NET 5/6/7/8/9+
- NuGet 접근 권한: NuGet 패키지를 설치할 수 있는 능력
- IronPDF 라이선스: ironpdf.com에서 라이선스 키를 획득하세요
NuGet 패키지 변경 사항
# Remove PdfPig
dotnet remove package PdfPig
# Install IronPDF
dotnet add package IronPdf
# Remove PdfPig
dotnet remove package PdfPig
# Install 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"
PdfPig사용 식별
# FindPdfPigusage
grep -r "UglyToad\.PdfPig\|PdfDocument\.Open\|GetPages\(\)" --include="*.cs" .
# Find page index references (may need 1→0 conversion)
grep -r "GetPage(\|NumberOfPages" --include="*.cs" .
# FindPdfPigusage
grep -r "UglyToad\.PdfPig\|PdfDocument\.Open\|GetPages\(\)" --include="*.cs" .
# Find page index references (may need 1→0 conversion)
grep -r "GetPage(\|NumberOfPages" --include="*.cs" .
완전한 API 참조
네임스페이스 변경
// Before: PdfPig
using UglyToad.PdfPig;
using UglyToad.PdfPig.Content;
using UglyToad.PdfPig.DocumentLayoutAnalysis.WordExtractor;
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
// Before: PdfPig
using UglyToad.PdfPig;
using UglyToad.PdfPig.Content;
using UglyToad.PdfPig.DocumentLayoutAnalysis.WordExtractor;
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
' Before: PdfPig
Imports UglyToad.PdfPig
Imports UglyToad.PdfPig.Content
Imports UglyToad.PdfPig.DocumentLayoutAnalysis.WordExtractor
' After: IronPDF
Imports IronPdf
Imports IronPdf.Rendering
문서 로딩 매핑
| PdfPig | IronPDF |
|---|---|
PdfDocument.Open(path) |
PdfDocument.FromFile(path) |
PdfDocument.Open(bytes) |
PdfDocument.FromBinaryData(bytes) |
PdfDocument.Open(stream) |
PdfDocument.FromStream(stream) |
using (var doc = ...) |
var pdf = ... |
페이지 접근 및 속성 매핑
| PdfPig | IronPDF |
|---|---|
document.NumberOfPages |
pdf.PageCount |
document.GetPages() |
pdf.Pages |
document.GetPage(1) |
pdf.Pages[0] |
텍스트 추출 매핑
| PdfPig | IronPDF |
|---|---|
page.Text |
pdf.Pages[i].Text |
page.GetWords() |
pdf.ExtractTextFromPage(i) |
| (manual loop) | pdf.ExtractAllText() |
메타데이터 접근 매핑
| PdfPig | IronPDF |
|---|---|
document.Information.Title |
pdf.MetaData.Title |
document.Information.Author |
pdf.MetaData.Author |
document.Information.Subject |
pdf.MetaData.Subject |
document.Information.Creator |
pdf.MetaData.Creator |
document.Information.Producer |
pdf.MetaData.Producer |
PdfPig에서 사용할 수 없는 새로운 기능
| IronPDF기능 | 설명 |
|---|---|
renderer.RenderHtmlAsPdf(html) |
HTML을 PDF로 변환 |
renderer.RenderUrlAsPdf(url) |
URL을 PDF로 변환 |
PdfDocument.Merge(pdfs) |
여러 PDF 병합 |
pdf.ApplyWatermark(html) |
워터마크 추가 |
pdf.SecuritySettings.UserPassword |
암호 보호 |
pdf.Sign(certificate) |
디지털 서명 |
코드 마이그레이션 예제
예제 1: PDF에서 텍스트 추출
이전 (PdfPig):
// NuGet: Install-Package PdfPig
using UglyToad.PdfPig;
using System;
using System.Text;
class Program
{
static void Main()
{
using (var document = PdfDocument.Open("input.pdf"))
{
var text = new StringBuilder();
foreach (var page in document.GetPages())
{
text.AppendLine(page.Text);
}
Console.WriteLine(text.ToString());
}
}
}
// NuGet: Install-Package PdfPig
using UglyToad.PdfPig;
using System;
using System.Text;
class Program
{
static void Main()
{
using (var document = PdfDocument.Open("input.pdf"))
{
var text = new StringBuilder();
foreach (var page in document.GetPages())
{
text.AppendLine(page.Text);
}
Console.WriteLine(text.ToString());
}
}
}
Imports UglyToad.PdfPig
Imports System
Imports System.Text
Class Program
Shared Sub Main()
Using document = PdfDocument.Open("input.pdf")
Dim text = New StringBuilder()
For Each page In document.GetPages()
text.AppendLine(page.Text)
Next
Console.WriteLine(text.ToString())
End Using
End Sub
End Class
이후 (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var pdf = PdfDocument.FromFile("input.pdf");
string text = pdf.ExtractAllText();
Console.WriteLine(text);
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var pdf = PdfDocument.FromFile("input.pdf");
string text = pdf.ExtractAllText();
Console.WriteLine(text);
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
Dim pdf = PdfDocument.FromFile("input.pdf")
Dim text As String = pdf.ExtractAllText()
Console.WriteLine(text)
End Sub
End Class
PdfPig와IronPDF둘 다 뛰어난 텍스트 추출 기능을 제공합니다. 주요 차이점은 코드 패턴에 있습니다. PdfPig은 using 문과 PdfDocument.Open()이 필요하며, GetPages()로 페이지를 수동으로 반복하고page.Text 속성에서 텍스트를 수집합니다.
IronPDF는 이를 단일 호출로 단순화합니다: PdfDocument.FromFile() 문서는 로드하고, ExtractAllText() 모든 텍스트 내용을 한 번에 반환합니다. using 문이 필요 없으며, 수동 반복도, StringBuilder도 필요하지 않습니다. 추가 옵션은 텍스트 추출 문서를 참조하세요.
예제 2: HTML을 PDF로 변환
이전 (PdfPig):
PdfPig는 HTML을 PDF로 변환하는 것을 지원하지 않습니다. PdfPig는 PDF를 읽고 구문 분석하는 라이브러리이며, PDF 생성 라이브러리가 아닙니다. HTML을 PDF로 변환하려면 다른 라이브러리를 사용해야 합니다.
이후 (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is a PDF from HTML</p>");
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is a PDF from HTML</p>");
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is a PDF from HTML</p>")
pdf.SaveAs("output.pdf")
End Sub
End Class
이 예제는 가장 중요한 기능 격차를 강조합니다. PdfPig는 명시적으로 'HTML을 PDF로 변환 지원하지 않음' 및 'PDF를 읽고/구문 분석하는 라이브러리, PDF 생성 라이브러리가 아님'을 명시합니다. PdfPig를 사용하여 HTML에서 PDF를 생성해야 하는 경우 완전히 다른 라이브러리를 사용해야 할 것입니다.
IronPDF는 ChromePdfRenderer을 통해 HTML을 PDF로 변환하는 네이티브 기능을 제공합니다. RenderHtmlAsPdf() 메서드는 HTML 문자열을 받아서 Chromium 엔진을 이용해 HTML, CSS, JavaScript를 정확하게 렌더링하여 PDF 문서로 변환합니다. 결과로 나온 PdfDocument은 SaveAs()로 저장하거나 저장하기 전에 추가로 조작할 수 있습니다. HTML에서 PDF로의 문서에서 포괄적인 예제를 참조하세요.
예제 3: PDF 메타데이터 읽기
이전 (PdfPig):
// NuGet: Install-Package PdfPig
using UglyToad.PdfPig;
using System;
class Program
{
static void Main()
{
using (var document = PdfDocument.Open("input.pdf"))
{
var info = document.Information;
Console.WriteLine($"Title: {info.Title}");
Console.WriteLine($"Author: {info.Author}");
Console.WriteLine($"Subject: {info.Subject}");
Console.WriteLine($"Creator: {info.Creator}");
Console.WriteLine($"Producer: {info.Producer}");
Console.WriteLine($"Number of Pages: {document.NumberOfPages}");
}
}
}
// NuGet: Install-Package PdfPig
using UglyToad.PdfPig;
using System;
class Program
{
static void Main()
{
using (var document = PdfDocument.Open("input.pdf"))
{
var info = document.Information;
Console.WriteLine($"Title: {info.Title}");
Console.WriteLine($"Author: {info.Author}");
Console.WriteLine($"Subject: {info.Subject}");
Console.WriteLine($"Creator: {info.Creator}");
Console.WriteLine($"Producer: {info.Producer}");
Console.WriteLine($"Number of Pages: {document.NumberOfPages}");
}
}
}
Imports UglyToad.PdfPig
Imports System
Class Program
Shared Sub Main()
Using document = PdfDocument.Open("input.pdf")
Dim info = document.Information
Console.WriteLine($"Title: {info.Title}")
Console.WriteLine($"Author: {info.Author}")
Console.WriteLine($"Subject: {info.Subject}")
Console.WriteLine($"Creator: {info.Creator}")
Console.WriteLine($"Producer: {info.Producer}")
Console.WriteLine($"Number of Pages: {document.NumberOfPages}")
End Using
End Sub
End Class
이후 (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var pdf = PdfDocument.FromFile("input.pdf");
var info = pdf.MetaData;
Console.WriteLine($"Title: {info.Title}");
Console.WriteLine($"Author: {info.Author}");
Console.WriteLine($"Subject: {info.Subject}");
Console.WriteLine($"Creator: {info.Creator}");
Console.WriteLine($"Producer: {info.Producer}");
Console.WriteLine($"Number of Pages: {pdf.PageCount}");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var pdf = PdfDocument.FromFile("input.pdf");
var info = pdf.MetaData;
Console.WriteLine($"Title: {info.Title}");
Console.WriteLine($"Author: {info.Author}");
Console.WriteLine($"Subject: {info.Subject}");
Console.WriteLine($"Creator: {info.Creator}");
Console.WriteLine($"Producer: {info.Producer}");
Console.WriteLine($"Number of Pages: {pdf.PageCount}");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
Dim pdf = PdfDocument.FromFile("input.pdf")
Dim info = pdf.MetaData
Console.WriteLine($"Title: {info.Title}")
Console.WriteLine($"Author: {info.Author}")
Console.WriteLine($"Subject: {info.Subject}")
Console.WriteLine($"Creator: {info.Creator}")
Console.WriteLine($"Producer: {info.Producer}")
Console.WriteLine($"Number of Pages: {pdf.PageCount}")
End Sub
End Class
두 라이브러리 모두 거의 동일한 패턴으로 메타데이터 접근을 제공합니다. PdfPig은 document.Information로 메타데이터에 접근하며 document.NumberOfPages를 통해 페이지 수를 확인합니다. IronPDF는 pdf.MetaData를 통해 메타데이터를, pdf.PageCount로 페이지 수를 사용합니다.
마이그레이션은 간단합니다: PdfDocument.Open()을 PdfDocument.FromFile()로, document.Information를 pdf.MetaData으로, document.NumberOfPages을 pdf.PageCount로 교체하세요. IronPDF는 필요하지 않으므로 using 문 래핑을 제거하세요.
중요한 마이그레이션 노트
페이지 색인 변경
PdfPig는 1-기반 인덱싱을 사용합니다; IronPDF는 0-기반을 사용합니다:
// PdfPig:1 기반indexing
var firstPage = document.GetPage(1); // First page
// IronPDF:0 기반indexing
var firstPage = pdf.Pages[0]; // First page
// Migration helper
int pdfPigIndex = 1;
int ironPdfIndex = pdfPigIndex - 1;
// PdfPig:1 기반indexing
var firstPage = document.GetPage(1); // First page
// IronPDF:0 기반indexing
var firstPage = pdf.Pages[0]; // First page
// Migration helper
int pdfPigIndex = 1;
int ironPdfIndex = pdfPigIndex - 1;
' PdfPig:1 기반indexing
Dim firstPage = document.GetPage(1) ' First page
' IronPDF:0 기반indexing
Dim firstPage = pdf.Pages(0) ' First page
' Migration helper
Dim pdfPigIndex As Integer = 1
Dim ironPdfIndex As Integer = pdfPigIndex - 1
사용 명령문이 필요 없습니다
// PdfPig: Requires using for disposal
using (var document = PdfDocument.Open("input.pdf"))
{
// ...
}
// IronPDF: No using required (but can use for cleanup)
var pdf = PdfDocument.FromFile("input.pdf");
// ...
// pdf.Dispose(); // Optional
// PdfPig: Requires using for disposal
using (var document = PdfDocument.Open("input.pdf"))
{
// ...
}
// IronPDF: No using required (but can use for cleanup)
var pdf = PdfDocument.FromFile("input.pdf");
// ...
// pdf.Dispose(); // Optional
Imports PdfPig
Imports IronPDF
Using document = PdfDocument.Open("input.pdf")
' ...
End Using
Dim pdf = PdfDocument.FromFile("input.pdf")
' ...
' pdf.Dispose() ' Optional
문서 로딩 변경
// PdfPig: PdfDocument.Open()
using (var document = PdfDocument.Open("input.pdf"))
// IronPDF: PdfDocument.FromFile()
var pdf = PdfDocument.FromFile("input.pdf");
// PdfPig: PdfDocument.Open()
using (var document = PdfDocument.Open("input.pdf"))
// IronPDF: PdfDocument.FromFile()
var pdf = PdfDocument.FromFile("input.pdf");
Imports PdfPig
Imports IronPDF
Using document = PdfDocument.Open("input.pdf")
End Using
Dim pdf = PdfDocument.FromFile("input.pdf")
메타데이터 속성명 변경
// PdfPig: document.Information
var info = document.Information;
// IronPDF: pdf.MetaData
var info = pdf.MetaData;
// PdfPig: document.Information
var info = document.Information;
// IronPDF: pdf.MetaData
var info = pdf.MetaData;
' PdfPig: document.Information
Dim info = document.Information
' IronPDF: pdf.MetaData
Dim info = pdf.MetaData
페이지 수 속성 변경
// PdfPig: document.NumberOfPages
Console.WriteLine($"Pages: {document.NumberOfPages}");
// IronPDF: pdf.PageCount
Console.WriteLine($"Pages: {pdf.PageCount}");
// PdfPig: document.NumberOfPages
Console.WriteLine($"Pages: {document.NumberOfPages}");
// IronPDF: pdf.PageCount
Console.WriteLine($"Pages: {pdf.PageCount}");
' PdfPig: document.NumberOfPages
Console.WriteLine($"Pages: {document.NumberOfPages}")
' IronPDF: pdf.PageCount
Console.WriteLine($"Pages: {pdf.PageCount}")
이동 후 새로운 기능
IronPDF로 마이그레이션한 후에는 PdfPig가 제공할 수 없는 기능을 얻게 됩니다:
PDF 병합
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
워터마크
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>")
비밀번호 보호
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword"
pdf.SecuritySettings.OwnerPassword = "ownerpassword"
디지털 서명
var signature = new PdfSignature("certificate.pfx", "password")
{
SigningContact = "support@company.com",
SigningReason = "Document Approval"
};
pdf.Sign(signature);
var signature = new PdfSignature("certificate.pfx", "password")
{
SigningContact = "support@company.com",
SigningReason = "Document Approval"
};
pdf.Sign(signature);
Dim signature As New PdfSignature("certificate.pfx", "password") With {
.SigningContact = "support@company.com",
.SigningReason = "Document Approval"
}
pdf.Sign(signature)
기능 비교 요약
| 기능 | PdfPig | IronPDF |
|---|---|---|
| 텍스트 추출 | ✓ | ✓ |
| 메타데이터 접근 | ✓ | ✓ |
| 이미지 추출 | ✓ | ✓ |
| PDF 생성 | 제한적 | ✓ |
| HTML to PDF | ✗ | ✓ |
| URL을 PDF로 변환 | ✗ | ✓ |
| PDF 병합 | ✗ | ✓ |
| PDF 분할 | ✗ | ✓ |
| 워터마크 | ✗ | ✓ |
| 폼 채우기 | ✗ | ✓ |
| 비밀번호 보호 | ✗ | ✓ |
| 디지털 서명 | ✗ | ✓ |
| 단어 위치 데이터 | ✓ | ✗ |
마이그레이션 체크리스트
사전 마이그레이션
- 코드베이스에서 모든PdfPig사용을 인벤토리하십시오
- 단어 수준 위치 데이터가 필요한지 식별하세요 (혼합 접근 방식 고려)
- 모든 페이지 인덱스 참조를 주의하세요 (1-기반에서 0-기반으로 변환) -IronPDF라이선스 키 저장 계획 (환경 변수 권장) -IronPDF체험판 라이선스로 먼저 테스트
패키지 변경 사항
PdfPigNuGet 패키지를 제거하십시오:dotnet remove package PdfPigIronPdfNuGet 패키지를 설치하십시오:dotnet add package IronPdf
코드 변경 사항
- 네임스페이스 임포트 업데이트 (
using UglyToad.PdfPig;→using IronPdf;) PdfDocument.Open()를PdfDocument.FromFile()로 교체하세요document.Information를pdf.MetaData로 교체하세요document.NumberOfPages를pdf.PageCount로 교체하세요- 페이지 인덱스를 1 기반에서 0 기반으로 변환합니다
using문장을 제거하세요 (옵션, IronPDF는 필요하지 않음)- 응용 프로그램 시작 시IronPDF라이선스 키를 추가합니다
마이그레이션 이후
- 텍스트 추출 출력이 예상과 일치하는지 테스트합니다
- 모든 PDF 생성 시나리오를 테스트합니다
- 필요에 따라 새로운 기능 추가 (병합, 워터마크, 보안)
- 리눅스에 배포하는 경우 리눅스 종속성을 설치합니다

