Remove last page from PDF and remove selective page from PDF

Hi,

how do i achieve removing of last page and a selective page from pdf using ASPOSE java?

Thanks

Hello Joanne,

Thanks for your interest in our products.

We have a component named Aspose.Pdf.Kit for Java which provides the capability to Manipulate/Edit existing PDF documents. In order to accomplish your requirement, you may consider using extract(…) method of PdfFileEditor class present under Aspose.Pdf.Kit for Java. This method provides the capability to extract certain ranges of pages from source PDF file and creates a new PDF document based over these pages. You may either consider using the extract(java.io.InputStream inputStream, int startPage, int endPage, java.io.OutputStream outputStream) overloaded method where you can specify the start and end page that need to be extracted from source PDF file or you may consider using extract(java.io.InputStream inputStream, int[] pageNumber, java.io.OutputStream outputStream) overloaded method where you specify the array of pages that need to be extracted from source PDF file. Please visit the following link for further details on Extract Pages from a PDF Document

Now concerning to remove the last page from PDF, you may consider using getNumberofPages(…) method of PdfFileInfo class which returns the total number of pages present in source file. You can use this information to determine the number of pages in your source PDF file, subtract -1 from Page count and pass this information as third argument to extract(java.io.InputStream inputStream, int startPage, int endPage, java.io.OutputStream outputStream) method, which will return the PDF file by ignoring the last page.

In case of any further query, please feel free to contact.