JPedal provides several methods to allow easy page deletion from PDF files.
These tools will allow you to create a copy of the PDF with the given pages and their content removed from the PDF. The original file is left untouched by this process unless you overwrite it with the output.
Delete Pages from PDF with the Command-Line or another language
java -cp jpedal.jar org.jpedal.tools.PdfPageDeletion
inputFile outputFile pageRangeString
The pageRange String is a page range as defined by SetOfIntegerSyntax. This range defines the pages to be deleted.
The following example deletes all pages from 2 to 100.
java -cp jpedal.jar org.jpedal.tools.PdfPageDeletion
inputFile outputFile "2-100"
Delete Pages from PDF in Java
Static Convenience Methods
//Delete all pages between rangeStart and rangeEnd inclusive
PdfPageDeletion.deletePageRange(new File("/path/to/input.pdf"), new File("/path/to/output.pdf"), rangeStart, rangeEnd);
//Delete all pages defined by the page range string using the SetOfIntegerSyntax
PdfPageDeletion.deletePageRange(new File("/path/to/input.pdf"), new File("/path/to/output.pdf"), stringPageRange);
//Delete a single page
PdfPageDeletion.deleteSinglePage(new File("/path/to/input.pdf"), new File("/path/to/output.pdf"), singlePageNumber;