Copy a selection of pages to new PDF files
by Mohan[ Edit ] 2012-09-21 13:46:48
Copy a selection of pages to new PDF files
import java.io.FileOutputStream;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
public class MainClass {
public static void main(String[] args) throws Exception {
PdfReader reader = new PdfReader("HelloWorldMultiplePages.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloSelectedOdd.pdf"));
reader.selectPages("o");
stamper.close();
reader = new PdfReader("HelloWorldMultiplePages.pdf");
stamper = new PdfStamper(reader, new FileOutputStream("HelloSelectedEven.pdf"));
reader.selectPages("e");
stamper.close();
reader = new PdfReader("HelloWorldMultiplePages.pdf");
stamper = new PdfStamper(reader, new FileOutputStream("HelloSelected12379.pdf"));
reader.selectPages("1-3, 7-9, !8");
stamper.close();
}
}