C#에서 IronPDF를 사용하여 여러 페이지로 구성된 PDF를 분할하는 방법 | IronPDF

C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분할하는 방법

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF는 다중 페이지 PDF 문서를 CopyPage 메서드를 사용하여 단일 페이지 PDF로 분할할 수 있게 합니다. 이 접근 방식을 사용하면 개발자는 단 몇 줄의 코드로 각 페이지를 반복적으로 처리하고 별도의 파일로 저장할 수 있습니다. 스캔한 문서, 보고서 또는 여러 페이지로 구성된 PDF 파일 등 어떤 종류의 문서를 다루든 IronPDF 효율적인 문서 관리 및 처리 솔루션을 제공합니다.

PDF 분할 기능은 개별 페이지를 다른 수신자에게 배포하거나, 페이지를 개별적으로 처리하거나, 단일 페이지 입력을 요구하는 문서 관리 시스템과 통합해야 할 때 특히 유용합니다. IronPDF의 강력한 Chrome 렌더링 엔진은 분할된 페이지가 원래 서식, 이미지 및 텍스트 품질을 유지하도록 보장합니다.

빠른 시작: 여러 페이지로 구성된 PDF를 단일 페이지로 분할

IronPDF 사용하면 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 빠르게 분할할 수 있습니다. CopyPage 메서드를 활용하면 PDF의 각 페이지를 효율적으로 반복하여 개별 파일로 저장할 수 있습니다. 이 간소화된 프로세스는 PDF 문서를 관리하는 빠르고 안정적인 솔루션을 찾는 개발자에게 적합합니다. 먼저 NuGet 통해 IronPDF 설치 되었는지 확인하십시오.

  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronPdf 설치하기

    PM > Install-Package IronPdf
  2. 다음 코드 조각을 복사하여 실행하세요.

    var pdf = new IronPdf.PdfDocument("multipage.pdf");
    for (int i = 0; i < pdf.PageCount; i++) {
      var singlePagePdf = pdf.CopyPage(i);
      singlePagePdf.SaveAs($"page_{i + 1}.pdf");
    }
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

    무료 체험판으로 오늘 프로젝트에서 IronPDF 사용 시작하기

    arrow pointer

PDF 문서 분할

  • IronPDF 라이브러리를 설치하세요
  • 여러 페이지로 구성된 PDF 파일을 단일 문서로 분할합니다.
Icon Quote related to C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분할...

이 종류의 라이브러리 중 가장 좋아하는 것은 IronPDF입니다. PDF 파일을 빠르고 효율적으로 조작할 수 있습니다. 또한 PDF/A 형식으로 내보내기 및 PDF 문서의 디지털 서명과 같은 많은 유용한 기능을 가지고 있습니다.

Milan Jovanovic related to C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분...

Milan Jovanovic

마이크로소프트 MVP

사례 연구 보기
Icon Quote related to C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분할...

IronOCR 덕분에 연간 $40,000를 수동 프로세싱에서 절약하고 생산성을 높이며 고부가가치 작업에 자원을 활용할 수 있습니다. 강력히 추천합니다.

Brent Matzelle related to C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분...

브렌트 마첼

최고 기술 책임자, OPYN

사례 연구 보기
Icon Quote related to C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분할...

IronSuite는 우리의 운영에서 중요한 역할을 합니다. 이것들은 사업 전반에 걸쳐 효율성을 높이는 도구로, 평면도 생성 및 재고 관리 개선을 포함합니다.

David Jones related to C#을 사용하여 여러 페이지로 구성된 PDF 파일을 단일 페이지 문서로 분할...

데이비드 존스

리드 소프트웨어 엔지니어, Agorus Build

사례 연구 보기

여러 페이지로 구성된 PDF 파일을 어떻게 분할하나요?

PDF 분할에 CopyPage 메서드를 사용하는 이유는?

이제 IronPDF를 사용하여 다중 페이지 문서를 단일 페이지 문서 파일로 분할할 수 있습니다. CopyPage 다중 페이지 PDF를 분할하는 아이디어는 CopyPage 또는 CopyPages 메서드를 사용하여 단일 페이지 또는 여러 페이지를 복사하는 것입니다. 이러한 메서드는 원본 문서의 모든 형식, 주석, 상호작용 요소를 유지하면서 지정된 페이지만 포함하는 새로운 PdfDocument 인스턴스를 생성합니다.

CopyPages IronPDF에서 PDF 분할 작업의 중심입니다. CopyPage 메서드는 다른 접근 방식과 달리 복잡한 조작이 필요하거나 데이터 유실 위험이 있는 CopyPage은 지정된 페이지의 정확한 복제본을 생성하여 모든 시각적 요소, 텍스트 서식 및 내장 리소스를 유지합니다. 이러한 특징 덕분에 법률 문서, 송장 또는 보관 기록과 같이 문서 무결성이 매우 중요한 상황에 이상적입니다.

각 페이지를 분할하는 단계는 무엇인가요?

CopyPages

보다 고급 시나리오의 경우 오류 처리를 구현하고 출력 형식을 사용자 지정할 수 있습니다. 다음은 유효성 검사 및 사용자 지정 이름 지정을 포함한 포괄적인 예입니다.

using IronPdf;
using System;
using System.IO;

public class PdfSplitter
{
    public static void SplitPdfWithValidation(string inputPath, string outputDirectory)
    {
        try
        {
            // Validate input file exists
            if (!File.Exists(inputPath))
            {
                throw new FileNotFoundException("Input PDF file not found.", inputPath);
            }

            // Create output directory if it doesn't exist
            Directory.CreateDirectory(outputDirectory);

            // Load the PDF document
            PdfDocument pdf = PdfDocument.FromFile(inputPath);

            // Get the file name without extension for naming split files
            string baseFileName = Path.GetFileNameWithoutExtension(inputPath);

            Console.WriteLine($"Splitting {pdf.PageCount} pages from {baseFileName}...");

            for (int idx = 0; idx < pdf.PageCount; idx++)
            {
                // Copy individual page
                PdfDocument singlePagePdf = pdf.CopyPage(idx);

                // Create descriptive filename with zero-padding for proper sorting
                string pageNumber = (idx + 1).ToString().PadLeft(3, '0');
                string outputPath = Path.Combine(outputDirectory, $"{baseFileName}_Page_{pageNumber}.pdf");

                // Save the single page PDF
                singlePagePdf.SaveAs(outputPath);

                Console.WriteLine($"Created: {outputPath}");
            }

            Console.WriteLine("PDF splitting completed successfully!");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error splitting PDF: {ex.Message}");
            throw;
        }
    }
}
using IronPdf;
using System;
using System.IO;

public class PdfSplitter
{
    public static void SplitPdfWithValidation(string inputPath, string outputDirectory)
    {
        try
        {
            // Validate input file exists
            if (!File.Exists(inputPath))
            {
                throw new FileNotFoundException("Input PDF file not found.", inputPath);
            }

            // Create output directory if it doesn't exist
            Directory.CreateDirectory(outputDirectory);

            // Load the PDF document
            PdfDocument pdf = PdfDocument.FromFile(inputPath);

            // Get the file name without extension for naming split files
            string baseFileName = Path.GetFileNameWithoutExtension(inputPath);

            Console.WriteLine($"Splitting {pdf.PageCount} pages from {baseFileName}...");

            for (int idx = 0; idx < pdf.PageCount; idx++)
            {
                // Copy individual page
                PdfDocument singlePagePdf = pdf.CopyPage(idx);

                // Create descriptive filename with zero-padding for proper sorting
                string pageNumber = (idx + 1).ToString().PadLeft(3, '0');
                string outputPath = Path.Combine(outputDirectory, $"{baseFileName}_Page_{pageNumber}.pdf");

                // Save the single page PDF
                singlePagePdf.SaveAs(outputPath);

                Console.WriteLine($"Created: {outputPath}");
            }

            Console.WriteLine("PDF splitting completed successfully!");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error splitting PDF: {ex.Message}");
            throw;
        }
    }
}
Imports IronPdf
Imports System
Imports System.IO

Public Class PdfSplitter
    Public Shared Sub SplitPdfWithValidation(inputPath As String, outputDirectory As String)
        Try
            ' Validate input file exists
            If Not File.Exists(inputPath) Then
                Throw New FileNotFoundException("Input PDF file not found.", inputPath)
            End If

            ' Create output directory if it doesn't exist
            Directory.CreateDirectory(outputDirectory)

            ' Load the PDF document
            Dim pdf As PdfDocument = PdfDocument.FromFile(inputPath)

            ' Get the file name without extension for naming split files
            Dim baseFileName As String = Path.GetFileNameWithoutExtension(inputPath)

            Console.WriteLine($"Splitting {pdf.PageCount} pages from {baseFileName}...")

            For idx As Integer = 0 To pdf.PageCount - 1
                ' Copy individual page
                Dim singlePagePdf As PdfDocument = pdf.CopyPage(idx)

                ' Create descriptive filename with zero-padding for proper sorting
                Dim pageNumber As String = (idx + 1).ToString().PadLeft(3, "0"c)
                Dim outputPath As String = Path.Combine(outputDirectory, $"{baseFileName}_Page_{pageNumber}.pdf")

                ' Save the single page PDF
                singlePagePdf.SaveAs(outputPath)

                Console.WriteLine($"Created: {outputPath}")
            Next

            Console.WriteLine("PDF splitting completed successfully!")
        Catch ex As Exception
            Console.WriteLine($"Error splitting PDF: {ex.Message}")
            Throw
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

페이지 반복은 어떻게 작동하나요?

위의 코드를 보면 현재 PDF 문서의 페이지를 반복하기 위해 for 루프를 사용하고 나서 각 페이지를 새 PdfDocument 객체에 복사하기 위해 CopyPage 메서드를 사용하는 것을 알 수 있습니다. CopyPage 마지막으로 각 페이지는 순차적으로 이름이 지정된 새 문서로 내보내집니다. IronPDF 복잡한 PDF 구조 조작을 모두 내부적으로 처리하므로 반복 프로세스는 간단하고 효율적입니다.

PageCount 속성은 문서의 총 페이지 수를 제공하여, 안전하게 반복하면서 인덱스 범위를 벗어난 예외를 방지할 수 있습니다. 각 반복 작업은 완전히 독립적인 PDF 문서를 생성하므로 원본 문서나 다른 분할된 페이지에 영향을 주지 않고 각 페이지를 개별적으로 처리, 수정 또는 배포할 수 있습니다. 이 접근 방식은 특정 페이지를 추출 하거나 페이지를 병렬로 처리해야 하는 대용량 문서를 다룰 때 특히 유용합니다.

CopyPages 대신 CopyPage을 언제 사용해야 하나요?

CopyPage 은 단일 페이지 추출에 완벽하며, IronPDF는 여러 개의 연속 또는 비연속 페이지를 추출해야 하는 시나리오를 위해 CopyPages 메서드를 제공합니다. 이 기능은 개별 페이지가 아닌 특정 페이지 범위를 포함하는 PDF 문서를 만들고자 할 때 특히 유용합니다.

using IronPdf;
using System.Collections.Generic;

public class MultiPageExtraction
{
    public static void ExtractPageRanges(string inputPath)
    {
        PdfDocument pdf = PdfDocument.FromFile(inputPath);

        // Extract pages 1-5 (0-indexed, so pages 0-4)
        List<int> firstChapter = new List<int> { 0, 1, 2, 3, 4 };
        PdfDocument chapterOne = pdf.CopyPages(firstChapter);
        chapterOne.SaveAs("Chapter_1.pdf");

        // Extract every other page (odd pages)
        List<int> oddPages = new List<int>();
        for (int i = 0; i < pdf.PageCount; i += 2)
        {
            oddPages.Add(i);
        }
        PdfDocument oddPagesDoc = pdf.CopyPages(oddPages);
        oddPagesDoc.SaveAs("Odd_Pages.pdf");

        // Extract specific non-consecutive pages
        List<int> selectedPages = new List<int> { 0, 4, 9, 14 }; // Pages 1, 5, 10, 15
        PdfDocument customSelection = pdf.CopyPages(selectedPages);
        customSelection.SaveAs("Selected_Pages.pdf");
    }
}
using IronPdf;
using System.Collections.Generic;

public class MultiPageExtraction
{
    public static void ExtractPageRanges(string inputPath)
    {
        PdfDocument pdf = PdfDocument.FromFile(inputPath);

        // Extract pages 1-5 (0-indexed, so pages 0-4)
        List<int> firstChapter = new List<int> { 0, 1, 2, 3, 4 };
        PdfDocument chapterOne = pdf.CopyPages(firstChapter);
        chapterOne.SaveAs("Chapter_1.pdf");

        // Extract every other page (odd pages)
        List<int> oddPages = new List<int>();
        for (int i = 0; i < pdf.PageCount; i += 2)
        {
            oddPages.Add(i);
        }
        PdfDocument oddPagesDoc = pdf.CopyPages(oddPages);
        oddPagesDoc.SaveAs("Odd_Pages.pdf");

        // Extract specific non-consecutive pages
        List<int> selectedPages = new List<int> { 0, 4, 9, 14 }; // Pages 1, 5, 10, 15
        PdfDocument customSelection = pdf.CopyPages(selectedPages);
        customSelection.SaveAs("Selected_Pages.pdf");
    }
}
Imports IronPdf
Imports System.Collections.Generic

Public Class MultiPageExtraction
    Public Shared Sub ExtractPageRanges(inputPath As String)
        Dim pdf As PdfDocument = PdfDocument.FromFile(inputPath)

        ' Extract pages 1-5 (0-indexed, so pages 0-4)
        Dim firstChapter As New List(Of Integer) From {0, 1, 2, 3, 4}
        Dim chapterOne As PdfDocument = pdf.CopyPages(firstChapter)
        chapterOne.SaveAs("Chapter_1.pdf")

        ' Extract every other page (odd pages)
        Dim oddPages As New List(Of Integer)()
        For i As Integer = 0 To pdf.PageCount - 1 Step 2
            oddPages.Add(i)
        Next
        Dim oddPagesDoc As PdfDocument = pdf.CopyPages(oddPages)
        oddPagesDoc.SaveAs("Odd_Pages.pdf")

        ' Extract specific non-consecutive pages
        Dim selectedPages As New List(Of Integer) From {0, 4, 9, 14} ' Pages 1, 5, 10, 15
        Dim customSelection As PdfDocument = pdf.CopyPages(selectedPages)
        customSelection.SaveAs("Selected_Pages.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

CopyPages 메서드는 사용자 지정 컴파일을 생성하거나 특정 섹션을 추출하거나 문서 콘텐츠를 재구성하는 데 이상적입니다. 여러 페이지가 필요할 때 여러 번 CopyPage 호출하는 것보다 더 효과적이며 단일 호출로 작업을 수행합니다. 포괄적인 PDF 조작 기능을 위해 분할 및 병합 작업을 결합하여 정교한 문서 워크플로를 만들 수 있습니다.

당신이 할 수 있는 다른 일들을 알아볼 준비가 되셨나요? PDF 정리 방법에 대한 튜토리얼 페이지는 여기에서 확인하세요. 분할된 PDF에 페이지 번호를 추가하는 방법이나 문서 관리 워크플로를 개선하기 위해 PDF 메타데이터를 관리하는 방법에 대해서도 알아볼 수 있습니다. 고급 PDF 조작 기술에 대해 알아보려면 우리의 포괄적인 API 레퍼런스를 방문하십시오.

자주 묻는 질문

C#에서 여러 페이지로 구성된 PDF 파일을 개별 단일 페이지 PDF 파일로 분할하려면 어떻게 해야 하나요?

IronPDF의 CopyPage 메서드를 사용하면 여러 페이지로 구성된 PDF를 분할할 수 있습니다. PDF 문서를 불러온 후, for 루프를 사용하여 각 페이지를 순회하고 각 페이지를 별도의 파일로 저장하면 됩니다. IronPDF는 단 몇 줄의 코드로 이 과정을 간소화하면서 원본의 서식과 품질을 모두 유지합니다.

PDF 파일에서 개별 페이지를 추출하려면 어떤 방법을 사용해야 할까요?

IronPDF는 PDF 문서에서 개별 페이지를 추출하는 CopyPage 메서드를 제공합니다. 이 메서드는 지정된 페이지의 정확한 복제본을 새 PdfDocument 인스턴스로 생성하며, 원본 문서의 모든 서식, 주석 및 대화형 요소를 그대로 유지합니다.

PDF 파일을 분할하면 원본 서식과 품질이 유지되나요?

네, IronPDF의 CopyPage 기능을 사용하여 PDF를 분할하면 모든 시각적 요소, 텍스트 서식, 포함된 리소스 및 대화형 요소가 보존됩니다. IronPDF의 Chrome 렌더링 엔진은 분할된 페이지가 원래 서식, 이미지 및 텍스트 품질을 유지하도록 보장합니다.

한 번에 여러 페이지를 분할할 수 있나요? 한 페이지씩 분할하는 대신에요.

네, IronPDF는 단일 페이지 복사와 여러 페이지 복사를 모두 지원합니다. CopyPages 메서드를 사용하면 여러 페이지를 한 번에 새로운 PdfDocument 인스턴스로 추출할 수 있어 다양한 분할 시나리오에 유연하게 대응할 수 있습니다.

PDF 문서를 분할하는 일반적인 사용 사례는 무엇인가요?

IronPDF의 분할 기능은 여러 수신자에게 개별 페이지를 배포하거나, 페이지를 개별적으로 처리하거나, 단일 페이지 입력이 필요한 문서 관리 시스템과 통합하거나, 문서 무결성이 중요한 법률 문서, 송장 또는 보관된 기록을 처리하는 데 이상적입니다.

Curtis Chau
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.

시작할 준비 되셨나요?
Nuget 다운로드 19,936,792 | 버전: 2026.7 방금 출시
Still Scrolling Icon

아직도 스크롤하고 계신가요?

빠른 증거를 원하시나요? PM > Install-Package IronPdf
샘플을 실행하세요 HTML이 PDF로 변환되는 것을 지켜보세요.