Import page : PDF Stamper « PDF « Java Tutorial


import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfCopy;
import com.lowagie.text.pdf.PdfReader;

public class MainClass {

  public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("HelloWorldMultiplePages.pdf");
    int pages = reader.getNumberOfPages();
    Document document = new Document();
    PdfCopy copy = new PdfCopy(document, new FileOutputStream("HelloWorldSelectPagesOdd.pdf"));;
    for (int i = 0; i < pages;) {
      copy.addPage(copy.getImportedPage(reader, i));



29.3.PDF Stamper
29.3.1.Stamping PDF file
29.3.2.Import page
29.3.3.Copy a selection of pages to new PDF files
29.3.4.Create PdfImportedPage