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
- Add JPedal to your class or module path (download the trial jar)
- Create a File handle pointing to the PDF file
- 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
What is JPedal?
JPedal is a commercial Java PDF Library that makes it easy for Java developers to work with PDF Documents in Java.
Why use JPedal?
JPedal makes it much easier to work with PDF files from Java. Because we have been actively developing our Java PDF Toolkit for over 20 years, it works with all those problem PDF files out there.
What licenses are available?
We have 2 licenses available:
'Server' for on premises and cloud servers and 'OEM' for use in a named end user applications. Both are one time fees with options support renewal after 12 months.
How to use JPedal?
Want to learn more about JPedal and how to use it, we have plenty of tutorials and guides to help you.