extract-pages
Extract PDF pages
Pull a chosen set of pages out into a new PDF.
- Reads
- a PDF — application/pdf
- Writes
- one file — PDFs
- Tool page
- /extract-pdf-pages
Example
Take the first three pages out of a long report and leave the rest behind.
Given
- report.pdf — an ordinary PDF of 10 pages
From code
import { loadDocument, runOperation } from '@pagecraft/core';
const report = await loadDocument({ bytes, name: 'report.pdf' });
const [output] = await runOperation('extract-pages', [report], {
pages: '1-3',
});
From a shell
pagecraft extract-pages report.pdf --pages 1-3
What comes back
One PDF of 3 pages.
This example is run by the test suite. If it stopped being true, the build would fail.
Options
pages--pages
string, a page selection: '1-3, 7, 9-', 'even', 'last'
Pages
Which pages to take, and in what order: '1-3, 7, 9-'.
Default: 'all'