Jacob Collins Jacob is a Java developer and the product manager of JPedal

How to remove a page from a PDF file in Java (Tutorial)

54 sec read

The PDF file format is not natively supported by Java. Therefore, to remove a page from a PDF file, you will need an external library. This tutorial explains how to do this using JPedal.
 

Getting Started

  1. Add JPedal to your class or module path (download the trial jar)
  2. Create a File handle pointing to the PDF file
  3. Call one of the methods below from PdfPageDeletion

 

How to remove a single page from a PDF

To remove a single page from a PDF file, simply call the following method.


How to remove pages in a range

To remove a range of pages from a PDF file, simply call the following method. Note that the range is inclusive.


How to remove multiple pages in a custom range

To remove a pages in multiple different ranges, simply call the following method. The page range must be defined using SetOfIntegerSyntax


How to remove pages using the command line

JPedal also allows you to remove pages from a PDF file through the command line


Before and After



The JPedal PDF library allows you to solve these problems in Java


Why do developers choose JPedal over alternatives?

  1. Actively developed commercial library with full support and no third party dependencies.
  2. Simple licensing options and source code access for OEM users.
  3. Process PDF files up to 3x faster than alternative Java PDF libraries.

Jacob Collins Jacob is a Java developer and the product manager of JPedal