---
title: "Split a PDF"
url: https://recursiveai.org/onepdf/cookbook/split-pdf/
description: "Split a PDF into one file per page, or into chosen page ranges, in C# with OnePDF. Bookmarks, links and form fields go with their pages."
version: "1.11.0"
---

# Split a PDF

Split a PDF into one file per page, or into chosen page ranges, in C# with OnePDF. Bookmarks, links and form fields go with their pages.

```csharp
using OnePdf;

using PdfDocument doc = PdfDocument.Open("report.pdf");

// One file per page.
IReadOnlyList<PdfDocument> pages = PdfDocument.Split(doc, pagesPerPart: 1);
for (int i = 0; i < pages.Count; i++)
{
    using PdfDocument part = pages[i];
    part.Save($"page-{i + 1}.pdf");
}

// Chosen ranges: pages 1-2 and pages 3-6. PdfPageRange takes a zero-based start and a count.
IReadOnlyList<PdfDocument> sections = PdfDocument.Split(doc, [new PdfPageRange(0, 2), new PdfPageRange(2, 4)]);
string[] names = ["intro.pdf", "body.pdf"];
for (int i = 0; i < sections.Count; i++)
{
    using PdfDocument part = sections[i];
    part.SetInfo("Title", $"Harbor trial report, {Path.GetFileNameWithoutExtension(names[i])}");
    part.Save(names[i]);
    Console.WriteLine($"{names[i]}: {part.PageCount} pages, {part.Outline.Count} bookmarks");
}
```

```text
intro.pdf: 2 pages, 2 bookmarks
body.pdf: 4 pages, 4 bookmarks
```

The run also wrote `page-1.pdf` to `page-6.pdf`, one page each.

- `Split(doc, pagesPerPart: n)` cuts the document into parts of `n` pages, the last one possibly shorter. `Split(doc, ranges)` makes one document per `PdfPageRange(start, count)`, with a zero-based start. To extract pages, pass a single range.
- Each part is a new document in memory that doesn’t refer to the source. Dispose each one after saving it.
- A part keeps the bookmarks that lead to its pages, the links between its own pages and the form fields whose widgets are on them.
- Parts carry no metadata from the source: set a title with `SetInfo` as the sample does.
- A resource dictionary that every page shares, common in slide decks, is copied whole into each part, so parts of such a file can be larger than their share of the original.

To put files together, see [Merge PDFs](https://recursiveai.org/onepdf/cookbook/merge-pdfs/). The rules are in [Page operations](https://recursiveai.org/onepdf/docs/page-operations/).

A longer walk-through, into single pages, page ranges, fixed-size parts or one file per bookmark: [Split a PDF in C#](https://recursiveai.org/onepdf/articles/split-pdf-csharp/).
