Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

Organize PDF pages

Extract selected pages from a PDF

Extract ranges such as 1-3,5,last into a new PDF, preserve the selected order, and leave the original document unchanged in the browser or .NET.

Extraction summary
Input
PDF and page selection
Output
Extracted PDF
Runs on
Browser-local WebAssembly or .NET
Microsoft Office
Not required
License
MIT

Page expressions are one-based and resolved against a PDF of at most 500 parsed pages in the browser.

Browse all PDF workflows

Practical steps

Extract a page range into a new PDF

Resolve a one-based page expression and write only the selected pages to a separate document.

  1. SelectChoose one PDF and review its page count.
  2. DescribeEnter a one-based expression such as 1-3,5,last.
  3. ExtractCreate and download the new PDF plus its operation report.

Use extraction when the output should contain only a specific subset of pages. The selector supports individual pages, ranges, comma-separated combinations, and last, which is resolved against the current source.

Extract from .NET

using OfficeIMO.Pdf;

PdfDocument source = PdfDocument.Load("case-file.pdf");
PdfPageSelector selection = PdfPageSelector.Parse("1-3,5,last");
PdfDocument extracted = source.Pages.Extract(selection);

File.WriteAllBytes("case-file.extract.pdf", extracted.ToBytes());

The result is a new PDF. Page numbers in the output are compacted to the new document order, while the source file remains unchanged.

Choose the right page operation

Extraction keeps the selected subset. Delete pages does the inverse and keeps everything except the selection. Reorder pages creates a document using the supplied sequence. Keeping these operations separate makes automated policy and user confirmation much clearer.

Example source

Download source