Put the pages of a PDF in a new order: move, swap, reverse or repeat pages, or interleave two scans, by listing the pages in the order you want.
Available in pre-release 3.7
List the pages in the new order:
sumatrapdf-tool clean in.pdf out.pdf 3,1,2,4-N. At a glance:- Any order:
3,1,2,4-N— page 3 first, then 1, 2, and 4 to the end. - Reverse:
N-1— last page first. - Move the last page to the front:
N,1--2 - Move the first page to the end:
2-N,1 - Repeat a page:
1,1-N— page 1 twice. - Pages from several files:
merge, see below. - Interleave front and back scans: a PowerShell loop, see below.
sumatrapdf-tool is installed with SumatraPDF and added to PATH. SumatraPDF.exe Put pages in a new order #
sumatrapdf-tool clean in.pdf out.pdf 3,1,2,4-N
out.pdf gets the pages of in.pdf in the order listed. Pages you don’t list are left out. Bookmarks are kept and point to the pages’ new positions.merge takes the same page list, with -o for the output:sumatrapdf-tool merge -o out.pdf in.pdf 3,1,2,4-N
Note: with a range written backwards (
N-1, 6-4) merge puts the pages in the right order but leaves bookmarks at their old page numbers. Use clean to reorder a single file.Page list syntax #
Comma-separated, no spaces. Pages are copied in the order written.
| Page list | Result on a 6-page PDF |
|---|---|
3,1,2,4-N |
3, 1, 2, 4, 5, 6 (N is the last page) |
1,3,2,4-N |
1, 3, 2, 4, 5, 6 (swap pages 2 and 3) |
N-1 |
6, 5, 4, 3, 2, 1 (reverse) |
6-4 |
6, 5, 4 (a range written backwards runs backwards) |
N,1--2 |
6, 1, 2, 3, 4, 5 (-2 is the second-to-last page) |
2-N,1 |
2, 3, 4, 5, 6, 1 |
1,1-N |
1, 1, 2, 3, 4, 5, 6 (a page listed twice is copied twice) |
-3--1 |
4, 5, 6 (the last three pages) |
Note:
1-N-1 does not mean “all but the last page”: it reads as 1-N followed by -1, and repeats the last page. Use 1--2.Page numbers past the end are cut to the last page:
4-9 on a 6-page PDF gives 4, 5, 6.Reverse the page order #
sumatrapdf-tool clean in.pdf reversed.pdf N-1
Move pages between documents #
merge takes pages from several files in one go, so you can insert pages from another PDF at any position. To put page 2 of cover.pdf first and all of appendix.pdf after page 10:sumatrapdf-tool merge -o out.pdf cover.pdf 2 in.pdf 1-10 appendix.pdf in.pdf 11-N
See Merge PDFs.
Interleave front and back scans #
A document scanned one side at a time gives two PDFs:
fronts.pdf (pages 1, 3, 5, …) and backs.pdf (pages …, 6, 4, 2: reversed, because the stack was turned over). To combine them in reading order, in PowerShell:$n = [int]((sumatrapdf-tool info fronts.pdf 1 | Select-String '^Pages: (\d+)').Matches[0].Groups[1].Value)
$parts = foreach ($i in 1..$n) { "fronts.pdf"; "$i"; "backs.pdf"; "$($n - $i + 1)" }
sumatrapdf-tool merge -o book.pdf @parts
For 3 sheets this runs
merge -o book.pdf fronts.pdf 1 backs.pdf 3 fronts.pdf 2 backs.pdf 2 fronts.pdf 3 backs.pdf 1. If backs.pdf is already in page order, use "$i" instead of "$($n - $i + 1)".Tips #
- Open the result in SumatraPDF and check the order before you delete the original.
- Use
Ctrl + K,Delete Pages From PDFin SumatraPDF to drop pages without reordering (Delete pages from PDF). - Use Rotate PDF pages for pages that are upside down or sideways.
See also #
- Merge PDFs — combine pages from several PDFs
- Split a PDF — one PDF into several
- Delete pages from PDF
- sumatrapdf-tool clean, merge
- All cmd-line tools