C# PDF 파서
IronPDF의 ExtractAllText 메소드를 사용하여 전체 문서 또는 특정 페이지에서 텍스트를 추출하며 C#에서 PDF 파일을 구문 분석합니다. 이 접근 방식은 단 몇 줄의 코드로 .NET 애플리케이션에서 간단하고 효율적인 PDF 텍스트 추출을 제공합니다.
IronPDF C# 애플리케이션에서 PDF 구문 분석을 간편하게 해줍니다. 이 튜토리얼에서는 IronPDF를 사용하여 PDF 생성 및 조작을 위한 포괄적인 C# 라이브러리로 PDF를 몇 단계만에 구문 분석하는 방법을 시연합니다.
빠른 시작: IronPDF 사용한 효율적인 PDF 구문 분석IronPDF 사용하여 최소한의 코드로 C#에서 PDF 파싱을 시작하세요. 이 예시는 PDF 파일의 원래 서식을 유지하면서 모든 텍스트를 추출하는 방법을 보여줍니다. IronPDF의 ExtractAllText 메소드는 .NET 애플리케이션에 원활한 PDF 구문 분석 통합을 가능하게 합니다. 간편한 설정 및 실행을 위해 다음 단계를 따르십시오.
-
1IronPDF를 NuGet Package Manager로 설치하십시오
-
2다음 코드 조각을 복사하여 실행하세요.
using IronPdf; var text = PdfDocument.FromFile("sample.pdf").ExtractAllText();Imports IronPdf Dim text = PdfDocument.FromFile("sample.pdf").ExtractAllText()Imports IronPdf Dim text = PdfDocument.FromFile("sample.pdf").ExtractAllText() -
3실제 운영 환경에서 테스트할 수 있도록 배포하세요.
오늘 프로젝트에서 IronPDF 사용을 시작해보세요 무료 체험
최소 워크플로우(5단계)
- Download C# PDF parser library
- Visual Studio에 설치하세요
ExtractAllText메서드를 사용하여 텍스트의 모든 줄을 추출합니다.ExtractTextFromPage메서드를 사용하여 한 페이지의 모든 텍스트를 추출합니다.- 구문 분석된 PDF 콘텐츠 보기
C#에서 PDF 파일을 파싱하는 방법은 무엇인가요?
IronPDF 사용하면 PDF 파일 파싱이 간단합니다. 아래 코드는 ExtractAllText 메소드를 사용하여 전체 PDF 문서에서 모든 텍스트 줄을 추출합니다. 비교 결과는 추출된 PDF 콘텐츠와 그 출력물을 함께 보여줍니다. 이 라이브러리는 또한 PDF 문서의 특정 섹션에서 텍스트 및 이미지 추출을 지원합니다.
입력
샘플 송장 PDF.
using IronPdf;
// Select the desired PDF File
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Extract all text from an pdf
string allText = pdf.ExtractAllText();
// Extract all text from page 1
string page1Text = pdf.ExtractTextFromPage(0);using IronPdf;
// Select the desired PDF File
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Extract all text from an pdf
string allText = pdf.ExtractAllText();
// Extract all text from page 1
string page1Text = pdf.ExtractTextFromPage(0);Imports IronPdf
' Select the desired PDF File
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Extract all text from an pdf
Private allText As String = pdf.ExtractAllText()
' Extract all text from page 1
Private page1Text As String = pdf.ExtractTextFromPage(0)Imports IronPdf
' Select the desired PDF File
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Extract all text from an pdf
Private allText As String = pdf.ExtractAllText()
' Extract all text from page 1
Private page1Text As String = pdf.ExtractTextFromPage(0)산출
실행하면 ExtractAllText 페이지 텍스트가 읽는 순서대로 반환됩니다:
Invoice INV-2026-0042
Billed to: Northwind Traders
Date: 2026-02-14
Consulting $3,200.00
Support $800.00
Total: $4,000.00
고급 텍스트 추출 예제
IronPDF 사용하여 PDF 콘텐츠를 분석하는 추가적인 방법은 다음과 같습니다.
입력
10페이지 보고서 문서.
using IronPdf;
using System;
// Parse PDF from URL
var pdfFromUrl = PdfDocument.FromUrl(new Uri("https://example.com/document.pdf"));
string urlPdfText = pdfFromUrl.ExtractAllText();
// Parse password-protected PDFs
var protectedPdf = PdfDocument.FromFile("protected.pdf", "password123");
string protectedText = protectedPdf.ExtractAllText();
// Extract text from specific page range
var largePdf = PdfDocument.FromFile("large-document.pdf");
for (int i = 5; i < 10; i++)
{
string pageText = largePdf.ExtractTextFromPage(i);
Console.WriteLine($"Page {i + 1}: {pageText.Substring(0, 100)}...");
}using IronPdf;
using System;
// Parse PDF from URL
var pdfFromUrl = PdfDocument.FromUrl(new Uri("https://example.com/document.pdf"));
string urlPdfText = pdfFromUrl.ExtractAllText();
// Parse password-protected PDFs
var protectedPdf = PdfDocument.FromFile("protected.pdf", "password123");
string protectedText = protectedPdf.ExtractAllText();
// Extract text from specific page range
var largePdf = PdfDocument.FromFile("large-document.pdf");
for (int i = 5; i < 10; i++)
{
string pageText = largePdf.ExtractTextFromPage(i);
Console.WriteLine($"Page {i + 1}: {pageText.Substring(0, 100)}...");
}Imports IronPdf
Imports System
' Parse PDF from URL
Dim pdfFromUrl = PdfDocument.FromUrl(New Uri("https://example.com/document.pdf"))
Dim urlPdfText As String = pdfFromUrl.ExtractAllText()
' Parse password-protected PDFs
Dim protectedPdf = PdfDocument.FromFile("protected.pdf", "password123")
Dim protectedText As String = protectedPdf.ExtractAllText()
' Extract text from specific page range
Dim largePdf = PdfDocument.FromFile("large-document.pdf")
For i As Integer = 5 To 9
Dim pageText As String = largePdf.ExtractTextFromPage(i)
Console.WriteLine($"Page {i + 1}: {pageText.Substring(0, 100)}...")
NextImports IronPdf
Imports System
' Parse PDF from URL
Dim pdfFromUrl = PdfDocument.FromUrl(New Uri("https://example.com/document.pdf"))
Dim urlPdfText As String = pdfFromUrl.ExtractAllText()
' Parse password-protected PDFs
Dim protectedPdf = PdfDocument.FromFile("protected.pdf", "password123")
Dim protectedText As String = protectedPdf.ExtractAllText()
' Extract text from specific page range
Dim largePdf = PdfDocument.FromFile("large-document.pdf")
For i As Integer = 5 To 9
Dim pageText As String = largePdf.ExtractTextFromPage(i)
Console.WriteLine($"Page {i + 1}: {pageText.Substring(0, 100)}...")
Next산출
URL 및 암호로 보호된 줄은 실시간 입력이 필요하지만, 페이지 범위 루프는 추출된 각 페이지를 콘솔에 기록합니다.

복잡한 구문 분석 필요 시 PDF DOM 객체 접근을 탐색하여 구조화된 콘텐츠를 다루십시오.
다양한 PDF 유형 처리
IronPDF 다양한 PDF 유형을 분석하는 데 탁월합니다.
using IronPdf;
using System.Text.RegularExpressions;
// Parse scanned PDFs with OCR (requires IronOcr)
var scannedPdf = PdfDocument.FromFile("scanned-document.pdf");
string ocrText = scannedPdf.ExtractAllText();
// Parse PDFs with forms
var formPdf = PdfDocument.FromFile("form.pdf");
string formText = formPdf.ExtractAllText();
// Extract and filter specific content
string invoiceText = pdf.ExtractAllText();
var invoiceNumber = Regex.Match(invoiceText, @"Invoice #: (\d+)").Groups[1].Value;
var totalAmount = Regex.Match(invoiceText, @"Total: \$([0-9,]+\.\d{2})").Groups[1].Value;using IronPdf;
using System.Text.RegularExpressions;
// Parse scanned PDFs with OCR (requires IronOcr)
var scannedPdf = PdfDocument.FromFile("scanned-document.pdf");
string ocrText = scannedPdf.ExtractAllText();
// Parse PDFs with forms
var formPdf = PdfDocument.FromFile("form.pdf");
string formText = formPdf.ExtractAllText();
// Extract and filter specific content
string invoiceText = pdf.ExtractAllText();
var invoiceNumber = Regex.Match(invoiceText, @"Invoice #: (\d+)").Groups[1].Value;
var totalAmount = Regex.Match(invoiceText, @"Total: \$([0-9,]+\.\d{2})").Groups[1].Value;Imports IronPdf
Imports System.Text.RegularExpressions
' Parse scanned PDFs with OCR (requires IronOcr)
Dim scannedPdf = PdfDocument.FromFile("scanned-document.pdf")
Dim ocrText As String = scannedPdf.ExtractAllText()
' Parse PDFs with forms
Dim formPdf = PdfDocument.FromFile("form.pdf")
Dim formText As String = formPdf.ExtractAllText()
' Extract and filter specific content
Dim invoiceText As String = pdf.ExtractAllText()
Dim invoiceNumber = Regex.Match(invoiceText, "Invoice #: (\d+)").Groups(1).Value
Dim totalAmount = Regex.Match(invoiceText, "Total: \$([0-9,]+\.\d{2})").Groups(1).ValueImports IronPdf
Imports System.Text.RegularExpressions
' Parse scanned PDFs with OCR (requires IronOcr)
Dim scannedPdf = PdfDocument.FromFile("scanned-document.pdf")
Dim ocrText As String = scannedPdf.ExtractAllText()
' Parse PDFs with forms
Dim formPdf = PdfDocument.FromFile("form.pdf")
Dim formText As String = formPdf.ExtractAllText()
' Extract and filter specific content
Dim invoiceText As String = pdf.ExtractAllText()
Dim invoiceNumber = Regex.Match(invoiceText, "Invoice #: (\d+)").Groups(1).Value
Dim totalAmount = Regex.Match(invoiceText, "Total: \$([0-9,]+\.\d{2})").Groups(1).ValueCAD 도면 및 지도 내보내기와 같은 계층화된 PDF는 별개의 유형이며, 콘텐츠가 이름이 지정된 선택적 콘텐츠 그룹(OCG)으로 그룹화되어 있습니다. 전체 문서를 구문 분석하는 대신, ExtractTextFromLayer를 사용하여 한 레이어로 추출을 제한하거나 ExtractTextFromLayers로 여러 레이어를 결합할 수 있습니다. 세부사항은 특정 계층에서 텍스트 추출을 참조하십시오.
파싱된 PDF 콘텐츠를 어떻게 볼 수 있나요?
AC# 폼은 위 코드 실행에서 파싱된 PDF 콘텐츠를 표시합니다. 이 출력은 문서 처리 요구 사항을 충족하기 위해 PDF에서 정확한 텍스트를 제공합니다.
추출된 텍스트는 PDF의 원래 서식과 구조를 그대로 유지하므로 데이터 처리, 콘텐츠 분석 또는 마이그레이션 작업에 적합합니다. 특정 콘텐츠 찾기 및 교체 또는 다른 형식으로 내보내기하여 이 텍스트를 추가 처리하십시오.
PDF 파싱 기능을 애플리케이션에 통합하기
IronPDF의 구문 분석 기능은 다양한 애플리케이션 유형에 통합될 수 있습니다.
// ASP.NET Core example
public IActionResult ParseUploadedPdf(IFormFile pdfFile)
{
using var stream = pdfFile.OpenReadStream();
var pdf = PdfDocument.FromStream(stream);
var extractedText = pdf.ExtractAllText();
// Process or store the extracted text
return Json(new {
success = true,
textLength = extractedText.Length,
preview = extractedText.Substring(0, Math.Min(500, extractedText.Length))
});
}
// Console application example
static void BatchParsePdfs(string folderPath)
{
var pdfFiles = Directory.GetFiles(folderPath, "*.pdf");
foreach (var file in pdfFiles)
{
var pdf = PdfDocument.FromFile(file);
var text = pdf.ExtractAllText();
// Save extracted text
var textFile = Path.ChangeExtension(file, ".txt");
File.WriteAllText(textFile, text);
Console.WriteLine($"Parsed: {Path.GetFileName(file)} - {text.Length} characters");
}
}// ASP.NET Core example
public IActionResult ParseUploadedPdf(IFormFile pdfFile)
{
using var stream = pdfFile.OpenReadStream();
var pdf = PdfDocument.FromStream(stream);
var extractedText = pdf.ExtractAllText();
// Process or store the extracted text
return Json(new {
success = true,
textLength = extractedText.Length,
preview = extractedText.Substring(0, Math.Min(500, extractedText.Length))
});
}
// Console application example
static void BatchParsePdfs(string folderPath)
{
var pdfFiles = Directory.GetFiles(folderPath, "*.pdf");
foreach (var file in pdfFiles)
{
var pdf = PdfDocument.FromFile(file);
var text = pdf.ExtractAllText();
// Save extracted text
var textFile = Path.ChangeExtension(file, ".txt");
File.WriteAllText(textFile, text);
Console.WriteLine($"Parsed: {Path.GetFileName(file)} - {text.Length} characters");
}
}' ASP.NET Core example
Public Function ParseUploadedPdf(pdfFile As IFormFile) As IActionResult
Using stream = pdfFile.OpenReadStream()
Dim pdf = PdfDocument.FromStream(stream)
Dim extractedText = pdf.ExtractAllText()
' Process or store the extracted text
Return Json(New With {
.success = True,
.textLength = extractedText.Length,
.preview = extractedText.Substring(0, Math.Min(500, extractedText.Length))
})
End Using
End Function
' Console application example
Shared Sub BatchParsePdfs(folderPath As String)
Dim pdfFiles = Directory.GetFiles(folderPath, "*.pdf")
For Each file In pdfFiles
Dim pdf = PdfDocument.FromFile(file)
Dim text = pdf.ExtractAllText()
' Save extracted text
Dim textFile = Path.ChangeExtension(file, ".txt")
File.WriteAllText(textFile, text)
Console.WriteLine($"Parsed: {Path.GetFileName(file)} - {text.Length} characters")
Next
End Sub' ASP.NET Core example
Public Function ParseUploadedPdf(pdfFile As IFormFile) As IActionResult
Using stream = pdfFile.OpenReadStream()
Dim pdf = PdfDocument.FromStream(stream)
Dim extractedText = pdf.ExtractAllText()
' Process or store the extracted text
Return Json(New With {
.success = True,
.textLength = extractedText.Length,
.preview = extractedText.Substring(0, Math.Min(500, extractedText.Length))
})
End Using
End Function
' Console application example
Shared Sub BatchParsePdfs(folderPath As String)
Dim pdfFiles = Directory.GetFiles(folderPath, "*.pdf")
For Each file In pdfFiles
Dim pdf = PdfDocument.FromFile(file)
Dim text = pdf.ExtractAllText()
' Save extracted text
Dim textFile = Path.ChangeExtension(file, ".txt")
File.WriteAllText(textFile, text)
Console.WriteLine($"Parsed: {Path.GetFileName(file)} - {text.Length} characters")
Next
End Sub이 예시들은 PDF 구문 분석 기능을 웹 애플리케이션 및 일괄 처리 시나리오에 통합하는 방법을 보여줍니다. 다양한 PDF를 처리할 때 성능을 향상시키기 위해 고급 구현을 위해서는 비동기 및 멀티스레딩 기술을 탐색하십시오.
당신이 할 수 있는 다른 일들을 알아볼 준비가 되셨나요? 여기에서 우리의 튜토리얼 페이지를 확인하세요: PDF 편집
자주 묻는 질문
C#을 사용하여 PDF에서 텍스트를 어떻게 추출합니까?
IronPDF의 ExtractAllText 메서드를 사용하여 전체 PDF 문서나 개별 페이지에서 손쉽게 텍스트를 추출할 수 있습니다. 몇 줄의 C# 코드만 필요합니다.
IronPDF에서 PDF 구문 분석에 어떤 메서드를 사용해야 합니까?
IronPDF의 ExtractAllText 메서드는 .NET 애플리케이션에서 PDF 문서로부터 효과적으로 텍스트를 추출할 수 있도록 합니다.
IronPDF는 PDF의 특정 페이지에서 텍스트를 추출할 수 있습니까?
예, IronPDF는 ExtractTextFromPage 메서드를 통해 특정 페이지에서 텍스트를 추출할 수 있으며, 이는 타겟 PDF 텍스트 추출에 유연합니다.
IronPDF는 암호로 보호된 PDF에서 텍스트를 추출할 수 있습니까?
예, IronPDF는 문서를 열 때 올바른 암호를 제공하여 암호로 보호된 PDF에서 텍스트를 추출할 수 있도록 합니다.
IronPDF는 URL에서 가져온 PDF를 구문 분석할 수 있습니까?
예. IronPDF의 PdfDocument.FromUrl 메서드를 사용하여 URL에서 직접 PDF를 구문 분석한 후 ExtractAllText로 그 텍스트를 추출할 수 있습니다.
IronPDF는 스캔된 문서에서 텍스트 추출을 어떻게 처리합니까?
PDF가 스캔된 문서인 경우 IronPDF는 OCR 기능(IronOcr로)을 활용하여 이미지 기반 PDF에서 텍스트를 추출할 수 있습니다.
IronPDF를 사용하여 PDF에서 특정 콘텐츠를 추출하고 필터링할 수 있습니까?
예, IronPDF는 모든 텍스트를 추출하고 정규 표현식이나 맞춤 로직을 활용하여 청구서 번호나 총액과 같은 특정 콘텐츠를 필터링하고 찾을 수 있습니다.
IronPDF를 사용하여 웹 애플리케이션에 PDF 구문 분석 기능을 어떻게 통합할 수 있습니까?
IronPDF의 구문 분석 기능을 ASP.NET Core와 같은 웹 애플리케이션에 통합하여 PDF 입력 스트림을 읽고 ExtractAllText를 사용하여 추출된 콘텐츠를 처리하거나 표시할 수 있습니다.
IronPDF에서 제공하는 고급 텍스트 추출 기능은 무엇입니까?
IronPDF는 특정 페이지 범위에서 텍스트를 구문 분석하고, 계층화된 PDF를 처리하며, 성능 향상을 위한 비동기 및 멀티쓰레딩을 지원하는 고급 기능을 제공합니다.
IronPDF는 텍스트를 추출할 때 원래 PDF의 형식을 유지할 수 있습니까?
예, IronPDF는 텍스트를 추출할 때 원래 PDF의 형식과 구조를 보존하도록 설계되어 있어 문서 처리 및 분석 작업에 적합합니다.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

