GroupDocs.Merger for Java

Extract PDF pages

With GroupDocs.Merger for Java, you can enhance your Java applications with powerful document processing features for PDF files.

How to extract PDF pages

GroupDocs.Merger allows you to extract pages from PDF documents easily. Enhance your Java applications by integrating advanced document management capabilities.

  1. Specify the file path of the source PDF document.
  2. Choose the pages you want to extract.
  3. Extract the selected pages.
  4. Save the extracted pages as a new document.
// Initialize GroupDocs.Merger with the source document
Merger merger = new Merger("document.pdf");

// Specify the pages to extract
ExtractOptions extractOptions = new ExtractOptions(new int[] { 2 });

// Perform the extraction process
merger.extractPages(extractOptions);

// Save the extracted pages as a new file
merger.save("result.pdf");
Maven XML
click to copy
copied
More examples Documentation

Comprehensive document processing

GroupDocs.Merger for Java offers a range of powerful features to process more than 50 widely used business file formats.

Key features of GroupDocs.Merger

Merge multiple document formats

Combine files like PDFs, Word documents, PowerPoint presentations, Excel spreadsheets, images, and archives. Customize merging options to meet your needs.

Page management

Work with specific pages or page ranges—move, remove, or reorder them to refine your business documents.

Adjust page layout

Rotate pages to any angle or change their orientation between landscape and portrait.

Extract selected pages

Extract only the pages you need and save them as a separate document.

Extract specific pages from a document

This example demonstrates how to extract a range of pages from a PDF document and save them as a separate file.

Java

// Provide the source file path
Merger merger = new Merger("file_1.pdf");

// Set options to extract only even-numbered pages within a range
ExtractOptions extractOptions = new ExtractOptions(1, 3, RangeMode.EvenPages);

// Execute the extraction operation
merger.extractPages(extractOptions);

// Save the extracted pages as a new document
merger.save("result.pdf");
Maven XML
click to copy
copied
More examples Documentation

About GroupDocs.Merger

GroupDocs.Merger for Java is a versatile document processing tool that supports over 50 file formats, including PDF, Word, Excel, PowerPoint, and images. It provides essential features such as merging, splitting, extracting, swapping, and removing pages.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Merger for free or get a trial license for full access!

Useful resources

Explore documentation, code samples, and community support to enhance your experience.

Key features

Explore additional document processing capabilities.

Extract pages from various document formats

GroupDocs.Merger supports over 50 file formats, enabling efficient document manipulation.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English