GroupDocs.Merger for Java

Delete pages in PDF

GroupDocs.Merger for Java enhances Java apps with powerful document processing features, including page removal in PDF files.

How to delete pages in PDF

GroupDocs.Merger allows you to easily remove pages from PDF documents. Enhance your Java applications with advanced document management capabilities.

  1. Specify the PDF file path.
  2. Define the pages to be deleted.
  3. Execute the page removal operation.
  4. Save the updated file.
// Create a Merger instance with the file path
Merger merger = new Merger("document.pdf");

// Specify the page number to delete
RemoveOptions removeOptions = new RemoveOptions(new int[] { 2 });

// Apply the page removal options
merger.removePages(removeOptions);

// Save the modified document
merger.save("result.pdf");
Maven XML
click to copy
copied
More examples Documentation

Advanced document processing

GroupDocs.Merger for Java provides a comprehensive set of features, allowing you to work with over 50 popular business file formats efficiently.

Key features of GroupDocs.Merger

Merge files in different formats

Combine PDFs, Word documents, presentations, spreadsheets, images, and archives with flexible merging options for precise results.

Page management

Rearrange document pages by moving, swapping, or deleting them to organize content effectively.

Modify page layout

Rotate pages to any angle or switch between landscape and portrait orientations.

Extract pages into separate files

Select specific pages and save them as standalone documents.

How to delete all even pages

Learn how to remove even-numbered pages from a PDF document.

Java

// Provide the file path to the constructor
Merger merger = new Merger("document.pdf");

// Retrieve the total number of pages
IDocumentInfo info = merger.getDocumentInfo();
int lastPage = info.PageCount;

// Define options to delete even pages
RemoveOptions removeOptions = new RemoveOptions(1, lastPage, RangeMode.EvenPages);

// Process the document
merger.removePages(removeOptions);

// Save the modified file to the desired location
merger.save("result.pdf");
Maven XML
click to copy
copied
More examples Documentation

About GroupDocs.Merger

GroupDocs.Merger for Java is a robust document processing tool that supports over 50 file formats, including PDF, Word, Excel, PowerPoint, Visio, images, and archives. It offers features such as merging, splitting, extracting, moving, swapping, and removing pages to enhance your applications.
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 powerful features of our solution.

Delete pages from multiple document formats

GroupDocs.Merger supports over 50 file formats, enabling fast and convenient document modifications.

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