Go to page 2 : Jump « PDF « Java Tutorial






import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfDestination;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();

    document.add(new Paragraph("1"));
    document.newPage();
    document.add(new Paragraph("2"));
    PdfContentByte cb = writer.getDirectContent();
    cb.localDestination("page2", new PdfDestination(PdfDestination.XYZ, -1, 10000, 0));
    writer.setOpenAction("page2");

    
    document.close();
  }
}








29.63.Jump
29.63.1.Use SimpleNamedDestination
29.63.2.Go to page 2
29.63.3.Remote Goto
29.63.4.Set Local Destination for chunk
29.63.5.Link to a Pdf file
29.63.6.Set up PdfDestination