Pagecraft

delete-pages

Delete PDF pages

Remove chosen pages from a PDF and keep the rest.

Reads
a PDF — application/pdf
Writes
one file — PDFs
Tool page
/delete-pages-from-pdf

Example

Drop the two blank pages a scanner left in the middle of a document.

Given

  • scanned.pdf — an ordinary PDF of 8 pages

From code

            import { loadDocument, runOperation } from '@pagecraft/core';

const scanned = await loadDocument({ bytes, name: 'scanned.pdf' });

const [output] = await runOperation('delete-pages', [scanned], {
  pages: '4,5',
});
          

From a shell

            pagecraft delete-pages scanned.pdf --pages 4,5
          

What comes back

One PDF of 6 pages.

This example is run by the test suite. If it stopped being true, the build would fail.

Options

pages--pagesRequired

string, a page selection: '1-3, 7, 9-', 'even', 'last'

Pages to delete

Which pages to remove: '2, 5-6'. Everything else is kept.