Use SimpleNamedDestination : Jump « PDF « Java Tutorial






import java.io.FileOutputStream;
import java.util.HashMap;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.SimpleNamedDestination;

public class MainClass {

  public static void main(String[] args) throws Exception {
    Document remote = new Document();
    PdfWriter.getInstance(remote, new FileOutputStream("remote.pdf"));

    remote.open();

    remote.add(new Paragraph("another"));
    remote.newPage();
    Paragraph p = new Paragraph("This paragraph contains a ");
    p.add(new Chunk("local destination").setLocalDestination("test"));
    remote.add(p);

    remote.close();
    PdfReader reader = new PdfReader("remote.pdf");
    HashMap map = SimpleNamedDestination.getNamedDestination(reader, false);
    SimpleNamedDestination.exportToXML(map, new FileOutputStream("remote.xml"), "ISO8859-1", true);
  }
}








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