{filelink=10390}
/***** Code de MesExemples.com *******/
/**
* @(#)PDFLocalDestination.java
*
*
* @author
*sakoba(java.mesexemples.com) @version 1.00 2013/4/27
*/
import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfDestination;
import com.itextpdf.text.pdf.PdfWriter;
public class PDFLocalDestination {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter pdf_writer = PdfWriter.getInstance(document,
new FileOutputStream("c:/PDFLocalDestination.pdf"));
document.open();
document.add(new Paragraph("Page 1"));
document.newPage();
document.add(new Paragraph("Page 2"));
PdfContentByte cb = pdf_writer.getDirectContent();
cb.localDestination("page2", new PdfDestination(PdfDestination.XYZ, -1,
10000, 0));
pdf_writer.setOpenAction("page2");
} catch (Exception err) {
err.printStackTrace();
}
document.close();
}
}