reorder
Reorder PDF pages
Rearrange every page of a PDF into an order you choose.
- Reads
- a PDF — application/pdf
- Writes
- one file — PDFs
- Tool page
- /reorder-pdf-pages
Example
Turn a document that came out back to front the right way round.
Given
- reversed.pdf — an ordinary PDF of 4 pages
From code
import { loadDocument, runOperation } from '@pagecraft/core';
const reversed = await loadDocument({ bytes, name: 'reversed.pdf' });
const [output] = await runOperation('reorder', [reversed], {
order: '4,3,2,1',
});
From a shell
pagecraft reorder reversed.pdf --order 4,3,2,1
What comes back
One PDF of 4 pages.
This example is run by the test suite. If it stopped being true, the build would fail.
Options
order--orderRequired
string, a page selection: '1-3, 7, 9-', 'even', 'last'
New order
Every page of the document, in the order you want them: '3, 1, 4, 2'. Reverse a document with '4-1'.
What it cannot do
- Every page has to appear exactly once. To drop pages, use Delete pages; to keep only some, use Extract pages.