split
Split PDF
Divide one PDF into several, at boundaries you choose.
- Reads
- a PDF — application/pdf
- Writes
- any number of files — PDFs
- Tool page
- /split-pdf
Example
Cut a six-page booklet into three files of two pages each.
Given
- booklet.pdf — an ordinary PDF of 6 pages
From code
import { loadDocument, runOperation } from '@pagecraft/core';
const booklet = await loadDocument({ bytes, name: 'booklet.pdf' });
const outputs = await runOperation('split', [booklet], {
mode: 'every',
size: 2,
});
From a shell
pagecraft split booklet.pdf --mode every --size 2
What comes back
3 PDFs of 2 pages.
This example is run by the test suite. If it stopped being true, the build would fail.
Options
mode--mode
string, one of
Split
Default: 'every'
after— Cut after page 3 and 7.every— A new file every 2 pages.parts— Three files of equal size.bookmarks— One file per top-level bookmark, named after it.
after--after
string, a page selection: '1-3, 7, 9-', 'even', 'last'
Cut after
The last page of each file: '3, 7' puts pages 1-3, 4-7 and 8- in three files.
Only when mode is 'after'.
Default: ''
size--size
integer
Pages per file
Only when mode is 'every'.
Default: 1
count--count
integer
Number of files
Only when mode is 'parts'.
Default: 2