Document Automation Made Simple

How to Split a PDF in C#: 4 Methods Compared (2026 Guide)

Compare the four practical ways to split PDF files in C# and .NET: iText 7, PdfSharp, Aspose.PDF, and the ConvertAPI REST service - with working code, honest limitations, and a decision table covering bookmark, regex, and range splits.

Tomas, CEO

Splitting a PDF in C# looks like a one-liner until the requirements arrive: split at every bookmark, start a new file when a regex matches, extract just the signed pages, keep memory flat on 500-page documents. This guide compares the four practical ways to split PDFs in C# and .NET - iText, PdfSharp, Aspose.PDF, and the ConvertAPI REST service - with working code for each, honest limitations, and a decision table.

Quick Comparison

Method License / cost Pages & ranges By bookmarks By text / regex Runs offline
iText (iText 7) AGPL or paid commercial Yes Manual outline parsing No Yes
PdfSharp MIT, free Yes No No Yes
Aspose.PDF Commercial, per developer Yes Manual No Yes
ConvertAPI Free trial, pay per conversion Yes Yes, one parameter Yes, regex No (REST API)

Method 1: iText 7

iText is the most capable open-source PDF library for .NET, and its PdfSplitter handles page-count splits cleanly:

using iText.Kernel.Pdf;
using iText.Kernel.Utils;

class Splitter : PdfSplitter
{
    private int _part = 1;
    public Splitter(PdfDocument doc) : base(doc) { }
    protected override PdfWriter GetNextPdfWriter(PageRange documentPageRange)
        => new PdfWriter($"output/part_{_part++}.pdf");
}

using var pdfDoc = new PdfDocument(new PdfReader("sample.pdf"));
foreach (var doc in new Splitter(pdfDoc).SplitByPageCount(1))
    doc.Close();

Limitations. The license is the big one: iText 7 is AGPL, so using it in a closed-source product requires a commercial license. Splitting by bookmarks means walking the outline tree yourself, and content-based splitting (a new file at every "Chapter N") is a manual text-extraction project.

Method 2: PdfSharp

PdfSharp is free (MIT) and perfect when all you need is page-level surgery:

using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;

var input = PdfReader.Open("sample.pdf", PdfDocumentOpenMode.Import);
for (var i = 0; i < input.PageCount; i++)
{
    var output = new PdfDocument();
    output.AddPage(input.Pages[i]);
    output.Save($"output/page_{i + 1}.pdf");
}

Limitations. PdfSharp only understands pages - there is no bookmark or content awareness at all, so anything smarter than fixed ranges is off the table. Encrypted files and some newer PDF features can also be problematic.

Method 3: Aspose.PDF

Aspose.PDF is a polished commercial library with the same page-loop pattern:

using Aspose.Pdf;

var document = new Document("sample.pdf");
var pageNumber = 1;
foreach (var page in document.Pages)
{
    var newDocument = new Document();
    newDocument.Pages.Add(page);
    newDocument.Save($"output/page_{pageNumber++}.pdf");
}

Limitations. Pricing starts at four figures per developer, the assembly is heavy, and large documents are constrained by server memory. Bookmark- and content-based splitting again mean custom code on top.

Method 4: ConvertAPI (Cloud API)

The Split PDF converter moves the work to an API call - which is what unlocks the split modes the libraries above cannot do in a few lines: bookmarks, regex text patterns, and mixed ranges, with no document-size memory pressure in your app.

Install the official .NET SDK and authenticate:

dotnet add package ConvertApi
using ConvertApiDotNet;

var convertApi = new ConvertApi("api-token");

Your API token lives in the dashboard.

Split by Bookmarks

Use the SplitByBookmark parameter to break your PDF at each bookmark level, generating a separate file for each bookmark entry:

var convert = await convertApi.ConvertAsync("pdf", "split",
    new ConvertApiFileParam("File", "files/sample.pdf"),
    new ConvertApiParam("SplitByBookmark", "true")
);
await convert.SaveFilesAsync("output/bookmark-splits");

Split a PDF by bookmarks

Split by Page-Count Pattern

To split your document into consecutive chunks of specified sizes, use the SplitByPattern parameter with a comma-separated sequence of positive integers. For example, "2,3" creates one file with the first 2 pages and a second file with the next 3 pages:

var convert = await convertApi.ConvertAsync("pdf", "split",
    new ConvertApiFileParam("File", "files/sample.pdf"),
    new ConvertApiParam("SplitByPattern", "2,3")
);
await convert.SaveFilesAsync("output/pattern-splits");

Split PDF by pattern

Split by Text Pattern (Regex)

Use the SplitByTextPattern parameter with a regular expression - each time the pattern matches, a new split begins. Ideal for dividing by chapters, sections, invoices in a batch print file, or any content marked by a consistent pattern:

var convert = await convertApi.ConvertAsync("pdf", "split",
    new ConvertApiFileParam("File", "files/sample.pdf"),
    new ConvertApiParam("SplitByTextPattern", @"Chapter\s+\d+")
);
await convert.SaveFilesAsync("output/text-pattern-splits");

Split PDF using regex

Extract Specific Pages

The ExtractPages parameter extracts a range and saves each page within it as a separate file. It accepts comma-separated page numbers or ranges (e.g., "5-10", "1,3,7"):

var convert = await convertApi.ConvertAsync("pdf", "split",
    new ConvertApiFileParam("File", "files/sample.pdf"),
    new ConvertApiParam("ExtractPages", "5-10")
);
await convert.SaveFilesAsync("output/extracted-pages");

Extract pages as individual files

Split by Ranges

Use the SplitByRange parameter to put exact pages or ranges into separate output files, combining individual pages and ranges with commas:

var convert = await convertApi.ConvertAsync("pdf", "split",
    new ConvertApiFileParam("File", "files/sample.pdf"),
    // Three output files: page 1, page 3, and pages 5-7 combined
    new ConvertApiParam("SplitByRange", "1,3,5-7")
);
await convert.SaveFilesAsync("output/split-by-ranges");

Split PDF by page ranges

Merge the Output into One File

Set MergeOutput to "true" alongside SplitByRange or ExtractPages to combine the selected pages into a single PDF instead of separate files - extract and reassemble in one call:

var convert = await convertApi.ConvertAsync("pdf", "split",
    new ConvertApiFileParam("File", "files/sample.pdf"),
    new ConvertApiParam("SplitByRange", "1,3,5-7"),
    new ConvertApiParam("MergeOutput", "true")
);
await convert.SaveFilesAsync("output/merged-range-output");

Merge splitted PDF output

Limitations. It is a REST API: your files travel over HTTPS to the conversion servers (encrypted in transit, deleted after processing), each conversion costs credits, and offline environments are out. The full example project is on GitHub: ConvertAPI Split PDF C# Examples.

Which Method Should You Choose?

  • PdfSharp - free page-range splitting in open or closed source. Fine when documents are simple and requirements stop at pages.
  • iText 7 - the most capable offline option if your project is AGPL-compatible or you buy the license, and you are ready to code bookmark and text logic yourself.
  • Aspose.PDF - commercial teams that want a supported offline library and can budget for it.
  • ConvertAPI - bookmark and regex splits with one parameter, no memory limits in your process, and the same API covers merge, compress, and 500+ other conversions.

Try It Yourself: Download the Sample Files

We split a four-page business deck into single pages with SplitByPattern=1 - these are the actual input and outputs:

Frequently Asked Questions

How do I split a PDF at every bookmark in C#?

With the libraries you must parse the outline tree and map bookmarks to page ranges manually. With ConvertAPI it is one parameter: SplitByBookmark=true.

How do I split a PDF into individual pages?

PdfSharp's page loop (Method 2) or SplitByPattern=1 with ConvertAPI - both produce one file per page.

Can I split password-protected PDFs?

ConvertAPI accepts the document password via the Password parameter. iText and Aspose can open encrypted files with the password too, while PdfSharp support is limited.

Does this work in .NET 6+ and .NET Core?

Yes - all four methods target .NET Standard and run on .NET 6, 8, and later, on Windows and Linux.

What about very large PDFs?

Library-based splitting holds documents in your process memory. With the API, size is not your app's problem - upload, split, download the parts.

Conclusion

For page-level splits in simple documents, a free library does the job. The moment splitting depends on document content - bookmarks, chapter headings, invoice markers - the one-parameter SplitByBookmark and SplitByTextPattern calls earn their keep. Head over to the Split PDF for C# page to try them with your own files - the interactive demo generates working code while you experiment.


Related converters

Ready to Streamline Your File Conversions?