# Split a PDF

Cut one PDF into several smaller PDFs: by page ranges, into parts of a fixed number of pages, or one file per page.

**Available in [pre-release 3.7](https://www.sumatrapdfreader.org/prerelease)**

**Take each part with `sumatrapdf-tool merge -o part1.pdf book.pdf 1-10`.** At a glance:

- **One part, in SumatraPDF:** **Extract Pages From PDF** (`CmdPdfExtractPages`).
- **Parts by page range:** one `merge` command per part.
- **One file per page:** a `for` loop in cmd.exe or PowerShell, or `draw -o page-%d.pdf`.
- **Parts of N pages:** a PowerShell loop.

`sumatrapdf-tool` is installed with SumatraPDF and added to PATH. [SumatraPDF.exe <tool>](Tools.md) takes the same arguments.

## Extract one part in SumatraPDF

1. Open the PDF.
2. Start **Extract Pages From PDF** in either of these ways:
   - Right-click the document → **Document → Extract Pages From PDF**
   - `Ctrl + K`, `Extract Pages From PDF` in [Command Palette](Command-Palette.md)
3. Check the destination path, and type the pages in **Pages To Extract:**, e.g. `11-20` or `2,5-7,13-` (`13-` means page 13 to the end).
4. Click **Extract Pages**. The new PDF opens in SumatraPDF.

Repeat for each part. More in [Extract pages from PDF](Tool-x-extract-pages-from-pdf.md).

## Split into parts by page ranges

Run one command per part:

```
sumatrapdf-tool merge -o part1.pdf book.pdf 1-10
sumatrapdf-tool merge -o part2.pdf book.pdf 11-20
sumatrapdf-tool merge -o part3.pdf book.pdf 21-N
```

`N` is the last page. For the page list syntax see [Merge PDFs](Merge-PDFs.md#pick-pages-from-each-file).

`clean` does the same; note the output file comes before the pages and there is no `-o`:

```
sumatrapdf-tool clean book.pdf part1.pdf 1-10
```

## Get the page count

The loops below need the number of pages. `info` prints it:

```
sumatrapdf-tool info book.pdf 1
```

Look for the `Pages: 120` line. The `1` at the end limits the rest of the report to page 1.

## Split into one file per page

In a cmd.exe window (replace `120` with the page count):

```
for /L %i in (1,1,120) do @sumatrapdf-tool merge -o page-%i.pdf book.pdf %i
```

In a `.bat` file, double the `%` signs. This one also reads the page count:

```
@echo off
for /f "tokens=2" %%n in ('sumatrapdf-tool info book.pdf 1 ^| findstr /b "Pages:"') do set N=%%n
for /L %%i in (1,1,%N%) do sumatrapdf-tool merge -o page-%%i.pdf book.pdf %%i
```

In PowerShell:

```
$n = [int]((sumatrapdf-tool info book.pdf 1 | Select-String '^Pages: (\d+)').Matches[0].Groups[1].Value)
1..$n | ForEach-Object { sumatrapdf-tool merge -o ("page-{0:D3}.pdf" -f $_) book.pdf $_ }
```

This names the files `page-001.pdf`, `page-002.pdf`, ... so they sort in page order.

### One command with `draw`

```
sumatrapdf-tool draw -o page-%d.pdf book.pdf
```

`%d` is replaced by the page number (`%03d` gives `page-001.pdf`). Add a page list to write only some pages: `draw -o page-%d.pdf book.pdf 1-2,7`. In a `.bat` file write `%%d`.

Note: `draw` redraws each page into a new PDF instead of copying it, so the files are bigger (in a test, 38 kB per page instead of 1 kB). Use the `merge` loop to keep pages exactly as they are.

## Split into parts of N pages

In PowerShell, parts of 10 pages named `book-1-10.pdf`, `book-11-20.pdf`, ...:

```
$n = [int]((sumatrapdf-tool info book.pdf 1 | Select-String '^Pages: (\d+)').Matches[0].Groups[1].Value)
$size = 10
for ($i = 1; $i -le $n; $i += $size) {
    $last = [Math]::Min($i + $size - 1, $n)
    sumatrapdf-tool merge -o "book-$i-$last.pdf" book.pdf "$i-$last"
}
```

## Tips

- Use `merge` rather than `draw` to split: pages, fonts and bookmarks are copied as they are.
- Bookmarks that point into a part are kept in that part.
- Run the loops in an empty folder, or put the output in a subfolder (`-o parts\page-%i.pdf`, after `mkdir parts`).
- To remove pages instead of splitting, see [Delete pages from PDF](Tool-x-delete-pages-from-pdf.md).

## See also

- [Merge PDFs](Merge-PDFs.md) — the reverse: several PDFs into one
- [Reorder pages in a PDF](Reorder-PDF-pages.md)
- [Batch process PDFs](Batch-process-PDFs.md) — run a tool over many files
- [Extract pages from PDF](Tool-x-extract-pages-from-pdf.md)
- [sumatrapdf-tool merge](Tool-merge.md), [clean](Tool-clean.md), [draw](Tool-draw.md), [info](Tool-info.md)
- [All cmd-line tools](Tools.md)
