Splitting PDFs means breaking one document into multiple files. Extract individual pages, create page ranges, or divide a 100-page report into 10-page chunks for easier distribution.
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("large-document.pdf");
// Extract pages 1-5 (indices 0-4)
var firstSection = pdf.CopyPages(0, 4);
firstSection.SaveAs("section-1.pdf");
// Extract pages 6-10 (indices 5-9)
var secondSection = pdf.CopyPages(5, 9);
secondSection.SaveAs("section-2.pdf");
IronPDF's CopyPages method extracts pages into new documents without modifying the original.
How Do I Split Into Single-Page Files?
Create individual files for each page:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("multipage-document.pdf");
for (int i = 0; i < pdf.PageCount; i++)
{
var singlePage = pdf.CopyPage(i);
singlePage.SaveAs($"page-{i + 1}.pdf");
singlePage.Dispose();
}
Console.WriteLine($"Split into {pdf.PageCount} individual files");
Each page becomes its own PDF file.
How Do I Extract a Page Range?
Get a specific section from a larger document:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("annual-report.pdf");
// Extract chapters (page numbers, 0-indexed)
var intro = pdf.CopyPages(0, 2); // Pages 1-3
intro.SaveAs("introduction.pdf");
var analysis = pdf.CopyPages(3, 15); // Pages 4-16
analysis.SaveAs("analysis.pdf");
var appendix = pdf.CopyPages(16, pdf.PageCount - 1); // Rest
appendix.SaveAs("appendix.pdf");
How Do I Split by Fixed Page Count?
Divide into equal-sized chunks:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void SplitByPageCount(string inputPath, int pagesPerFile, string outputFolder)
{
var pdf = PdfDocument.FromFile(inputPath);
int totalPages = pdf.PageCount;
int fileIndex = 1;
for (int start = 0; start < totalPages; start += pagesPerFile)
{
int end = Math.Min(start + pagesPerFile - 1, totalPages - 1);
var section = pdf.CopyPages(start, end);
var outputPath = Path.Combine(outputFolder, $"part-{fileIndex}.pdf");
section.SaveAs(outputPath);
section.Dispose();
Console.WriteLine($"Created: part-{fileIndex}.pdf (pages {start + 1}-{end + 1})");
fileIndex++;
}
pdf.Dispose();
}
// Usage: Split into 10-page chunks
SplitByPageCount("large-report.pdf", 10, "C:/Output");
A 45-page document becomes 5 files: four with 10 pages, one with 5.
How Do I Extract Specific Pages?
Pick non-consecutive pages:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("document.pdf");
// Extract pages 1, 5, 10, 15 (0-indexed: 0, 4, 9, 14)
int[] pagesToExtract = { 0, 4, 9, 14 };
var extracted = PdfDocument.FromFile("document.pdf").CopyPage(pagesToExtract[0]);
for (int i = 1; i < pagesToExtract.Length; i++)
{
var page = pdf.CopyPage(pagesToExtract[i]);
extracted = PdfDocument.Merge(extracted, page);
}
extracted.SaveAs("selected-pages.pdf");
How Do I Remove Pages from a PDF?
Remove unwanted pages by keeping the rest:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("document.pdf");
// Remove page 3 (index 2)
pdf.RemovePage(2);
// Remove multiple pages (remove from end to preserve indices)
int[] pagesToRemove = { 10, 7, 3 }; // Sorted descending
foreach (int pageIndex in pagesToRemove.OrderByDescending(p => p))
{
pdf.RemovePage(pageIndex);
}
pdf.SaveAs("trimmed-document.pdf");
Remove from highest index first to avoid shifting issues.
How Do I Split Even and Odd Pages?
Separate for duplex printing:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void SplitEvenOdd(string inputPath)
{
var pdf = PdfDocument.FromFile(inputPath);
var oddPages = new List<int>();
var evenPages = new List<int>();
for (int i = 0; i < pdf.PageCount; i++)
{
if ((i + 1) % 2 == 1) // Page numbers are 1-based
oddPages.Add(i);
else
evenPages.Add(i);
}
// Create odd pages document
if (oddPages.Count > 0)
{
var oddDoc = pdf.CopyPage(oddPages[0]);
for (int i = 1; i < oddPages.Count; i++)
{
var page = pdf.CopyPage(oddPages[i]);
oddDoc = PdfDocument.Merge(oddDoc, page);
}
oddDoc.SaveAs("odd-pages.pdf");
}
// Create even pages document
if (evenPages.Count > 0)
{
var evenDoc = pdf.CopyPage(evenPages[0]);
for (int i = 1; i < evenPages.Count; i++)
{
var page = pdf.CopyPage(evenPages[i]);
evenDoc = PdfDocument.Merge(evenDoc, page);
}
evenDoc.SaveAs("even-pages.pdf");
}
}
How Do I Split Based on File Size?
Create files under a size limit:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void SplitBySize(string inputPath, long maxSizeBytes, string outputFolder)
{
var pdf = PdfDocument.FromFile(inputPath);
int fileIndex = 1;
int startPage = 0;
while (startPage < pdf.PageCount)
{
var section = pdf.CopyPage(startPage);
int endPage = startPage;
// Keep adding pages until size limit approached
while (endPage + 1 < pdf.PageCount)
{
var nextPage = pdf.CopyPage(endPage + 1);
var testMerge = PdfDocument.Merge(section, nextPage);
if (testMerge.BinaryData.Length > maxSizeBytes)
{
testMerge.Dispose();
break;
}
section = testMerge;
endPage++;
}
var outputPath = Path.Combine(outputFolder, $"part-{fileIndex}.pdf");
section.SaveAs(outputPath);
Console.WriteLine($"Created: part-{fileIndex}.pdf ({section.BinaryData.Length / 1024} KB)");
section.Dispose();
startPage = endPage + 1;
fileIndex++;
}
}
// Usage: Split into files under 5MB
SplitBySize("huge-document.pdf", 5 * 1024 * 1024, "C:/Output");
How Do I Extract the First/Last N Pages?
Common extraction patterns:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("document.pdf");
// First 5 pages
var firstFive = pdf.CopyPages(0, 4);
firstFive.SaveAs("first-five.pdf");
// Last 5 pages
int lastStart = Math.Max(0, pdf.PageCount - 5);
var lastFive = pdf.CopyPages(lastStart, pdf.PageCount - 1);
lastFive.SaveAs("last-five.pdf");
// Everything except first page (cover)
var withoutCover = pdf.CopyPages(1, pdf.PageCount - 1);
withoutCover.SaveAs("no-cover.pdf");
// Everything except last page
var withoutLast = pdf.CopyPages(0, pdf.PageCount - 2);
withoutLast.SaveAs("no-appendix.pdf");
How Do I Batch Split Multiple PDFs?
Process an entire folder:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void BatchSplit(string inputFolder, string outputFolder, int pagesPerFile)
{
var files = Directory.GetFiles(inputFolder, "*.pdf");
foreach (var file in files)
{
var baseName = Path.GetFileNameWithoutExtension(file);
var pdf = PdfDocument.FromFile(file);
int partIndex = 1;
for (int start = 0; start < pdf.PageCount; start += pagesPerFile)
{
int end = Math.Min(start + pagesPerFile - 1, pdf.PageCount - 1);
var section = pdf.CopyPages(start, end);
var outputPath = Path.Combine(outputFolder, $"{baseName}-part{partIndex}.pdf");
section.SaveAs(outputPath);
section.Dispose();
partIndex++;
}
Console.WriteLine($"Split {baseName}: {partIndex - 1} parts");
pdf.Dispose();
}
}
How Do I Split and Name by Content?
If you know page structure, name files meaningfully:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void SplitReport(string reportPath, string outputFolder)
{
var pdf = PdfDocument.FromFile(reportPath);
// Known structure: Cover (1), TOC (1), Intro (3), Body (varies), Appendix (5)
var sections = new (string name, int startPage, int endPage)[]
{
("cover", 0, 0),
("table-of-contents", 1, 1),
("introduction", 2, 4),
("main-content", 5, pdf.PageCount - 6),
("appendix", pdf.PageCount - 5, pdf.PageCount - 1)
};
foreach (var (name, start, end) in sections)
{
if (start <= end && end < pdf.PageCount)
{
var section = pdf.CopyPages(start, end);
section.SaveAs(Path.Combine(outputFolder, $"{name}.pdf"));
section.Dispose();
}
}
}
Quick Reference
| Operation | Code |
|---|---|
| Copy single page | pdf.CopyPage(pageIndex) |
| Copy page range | pdf.CopyPages(startIndex, endIndex) |
| Remove page | pdf.RemovePage(pageIndex) |
| Get page count | pdf.PageCount |
| Merge PDFs | PdfDocument.Merge(pdf1, pdf2) |
| Common Pattern | Range (0-indexed) |
|---|---|
| First N pages |
0 to N - 1
|
| Last N pages |
PageCount - N to PageCount - 1
|
| Pages X to Y |
X - 1 to Y - 1
|
| Skip first page |
1 to PageCount - 1
|
Remember: page indices are zero-based. Page 1 = index 0.
Splitting PDFs enables document management workflows—distribute sections to different teams, archive by chapter, or create email-friendly file sizes.
For more splitting options, see the IronPDF split documentation.
Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads a team of 50+ engineers building .NET document processing libraries.
Top comments (0)